# HG changeset patch # User bjarni # Date 1172622820 0 # Node ID 4b5241e5dd102939c864411fc50c610fb2f65b1e # Parent 7c8ec33959b1a7788a41e4c3a0d2a58270271b8d (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900) diff -r 7c8ec33959b1 -r 4b5241e5dd10 Makefile.in --- a/Makefile.in Tue Feb 27 23:54:28 2007 +0000 +++ b/Makefile.in Wed Feb 28 00:33:40 2007 +0000 @@ -30,6 +30,7 @@ OS = !!OS!! OSXAPP = !!OSXAPP!! REVISION = !!REVISION!! +AWK = !!AWK!! RES := $(shell if ! [ -f $(CONFIG_CACHE_SOURCE_LIST) ] || [ -n "`cmp $(CONFIG_CACHE_SOURCE_LIST) $(SOURCE_LIST)`" ]; then cp $(SOURCE_LIST) $(CONFIG_CACHE_SOURCE_LIST); fi ) @@ -118,7 +119,7 @@ # Find if the local source if modified REV_MODIFIED := $(shell svnversion $(SRC_DIR) | sed -n 's/.*\(M\).*/\1/p' ) # Find the revision like: rXXXX-branch -REV := $(shell LC_ALL=C svn info $(SRC_DIR) | awk '/^URL:.*branches/ { split($$2, a, "/"); BRANCH="-"a[5] } /^Last Changed Rev:/ { REV="r"$$4"$(REV_MODIFIED)" } END { print REV BRANCH }') +REV := $(shell LC_ALL=C svn info $(SRC_DIR) | $(AWK) '/^URL:.*branches/ { split($$2, a, "/"); BRANCH="-"a[5] } /^Last Changed Rev:/ { REV="r"$$4"$(REV_MODIFIED)" } END { print REV BRANCH }') endif endif # Make sure we have something in REV diff -r 7c8ec33959b1 -r 4b5241e5dd10 Makefile.src.in --- a/Makefile.src.in Tue Feb 27 23:54:28 2007 +0000 +++ b/Makefile.src.in Wed Feb 28 00:33:40 2007 +0000 @@ -27,6 +27,7 @@ CFLAGS_MAKEDEP= !!CFLAGS_MAKEDEP!! SORT = !!SORT!! REVISION = !!REVISION!! +AWK = !!AWK!! CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!! CONFIG_CACHE_LINKER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!! CONFIG_CACHE_ENDIAN = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_ENDIAN!! @@ -82,7 +83,7 @@ # Find if the local source if modified REV_MODIFIED := $(shell svnversion $(SRC_DIR) | sed -n 's/.*\(M\).*/\1/p' ) # Find the revision like: rXXXX-branch -REV := $(shell LC_ALL=C svn info $(SRC_DIR) | awk '/^URL:.*branch/ { split($$2, a, "/"); BRANCH="-"a[5] } /^Last Changed Rev:/ { REV="r"$$4"$(REV_MODIFIED)" } END { print REV BRANCH }') +REV := $(shell LC_ALL=C svn info $(SRC_DIR) | $(AWK) '/^URL:.*branch/ { split($$2, a, "/"); BRANCH="-"a[5] } /^Last Changed Rev:/ { REV="r"$$4"$(REV_MODIFIED)" } END { print REV BRANCH }') endif endif # Make sure we have something in REV @@ -159,14 +160,14 @@ # Convert x:/... paths to /x/... for mingw ifeq ($(OS), MINGW) - @cat Makefile.dep.tmp | sed 's@\([a-zA-Z]\):/@/\1/@g' > Makefile.dep.tmp.mingw + @cat Makefile.dep.tmp | sed 's@\([a-zA-Z]\):\/@\/\1\/@g' > Makefile.dep.tmp.mingw @cp Makefile.dep.tmp.mingw Makefile.dep.tmp @rm -f Makefile.dep.tmp.mingw endif # Remove all comments and includes that don't start with $(SRC_DIR) # Remove $(SRC_DIR) from object-file-name - @awk ' \ + @$(AWK) ' \ /^# DO NOT/ { print $$0 ; next} \ /^#/ {next} \ /:/ { \ @@ -225,6 +226,9 @@ $(TTD): rev.o $(OBJS) $(CONFIG_CACHE_LINKER) $(E) '$(STAGE) Linking $@' ifeq ($(OS), PSP) + # Because of a bug in the PSP GCC tools, linking via CXX results + # in total chaos and more problems then you can handle. So we need + # CC to link OpenTTD for PSP $(Q)$(CC_HOST) $(LDFLAGS) rev.o $(OBJS) $(LIBS) -o $@ else $(Q)$(CXX_HOST) $(LDFLAGS) rev.o $(OBJS) $(LIBS) -o $@ diff -r 7c8ec33959b1 -r 4b5241e5dd10 bin/data/openttd.grf Binary file bin/data/openttd.grf has changed diff -r 7c8ec33959b1 -r 4b5241e5dd10 config.lib --- a/config.lib Tue Feb 27 23:54:28 2007 +0000 +++ b/config.lib Wed Feb 28 00:33:40 2007 +0000 @@ -17,6 +17,7 @@ windres="" strip="" lipo="" + awk="awk" os="DETECT" endian="AUTO" revision="" @@ -57,7 +58,7 @@ with_fontconfig="1" with_psp_config="1" - save_params_array="build host cc_build cc_host cxx_build cxx_host windres strip lipo os revision endian config_log prefix_dir binary_dir data_dir icon_dir personal_dir install_dir custom_lang_dir second_data_dir enable_install enable_debug enable_profiling enable_dedicated enable_network enable_static enable_translator enable_assert enable_strip with_osx_sysroot enable_universal enable_osx_g5 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 CC CXX CFLAGS LDFLAGS" + save_params_array="build host cc_build cc_host cxx_build cxx_host windres strip awk lipo os revision endian config_log prefix_dir binary_dir data_dir icon_dir personal_dir install_dir custom_lang_dir second_data_dir enable_install enable_debug enable_profiling enable_dedicated enable_network enable_static enable_translator enable_assert enable_strip with_osx_sysroot enable_universal enable_osx_g5 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 CC CXX CFLAGS LDFLAGS" } detect_params() { @@ -99,6 +100,8 @@ --cxx-host=*) cxx_host="$optarg";; --windres) prevp_p="windres";; --windres=*) windres="$optarg";; + --awk) prevp_p="awk";; + --awk=*) awk="$optarg";; --strip) prevp_p="strip";; --strip=*) strip="$optarg";; --lipo) prevp_p="lipo";; @@ -285,30 +288,32 @@ # Some params want to be in full uppercase, else they might not work as # expected.. fix that here - endian=`echo $endian | tr [:lower:] [:upper:]` - os=`echo $os | tr [:lower:] [:upper:]` + endian=`echo $endian | tr '[a-z]' '[A-Z]'` + os=`echo $os | tr '[a-z]' '[A-Z]'` # Check if all params have valid values # Endian only allows AUTO, LE and, BE - if ! echo $endian | grep -Eq "^(AUTO|LE|BE)$"; then + if [ -z "`echo $endian | egrep '^(AUTO|LE|BE)$'`" ]; then echo "configure: error: invalid option --endian=$endian" echo " Available options are: --endian=[AUTO|LE|BE]" exit 1 fi # OS only allows DETECT, UNIX, OSX, FREEBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, WINCE, and PSP - if ! echo $os | grep -Eq "^(DETECT|UNIX|OSX|FREEBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|WINCE|PSP)$"; then + if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|WINCE|PSP)$'`" ]; then echo "configure: error: invalid option --os=$os" echo " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|WINCE|PSP]" exit 1 fi # enable_debug should be between 0 and 4 - if ! echo $enable_debug | grep -q "^[0123]$"; then + if [ -z "`echo $enable_debug | grep '^[0123]$'`" ]; then echo "configure: error: invalid option --enable-debug=$enable_debug" echo " Available options are: --enable-debug[=0123]" exit 1 fi + detect_awk + check_build check_host @@ -336,7 +341,11 @@ check_cxx_build check_cxx_host check_windres - check_strip + if [ "$enable_strip" != "0" ]; then + check_strip + else + log 1 "checking strip... disabled" + fi check_lipo check_makedepend @@ -548,7 +557,7 @@ log 1 "detecting G5... yes (forced)" else # First, are we a real OSX system, else we can't detect it - native=`LC_ALL=C uname | tr [:upper:] [:lower:] | grep darwin` + native=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | grep darwin` # If $host doesn't match $build , we are cross-compiling if [ -n "$native" ] && [ "$build" != "$host" ]; then $cc_build $SRC_DIR/os/macosx/G5_detector.cpp -o G5_detector @@ -602,6 +611,7 @@ if [ "$os" = "MORPHOS" ]; then CFLAGS="$CFLAGS -I/gg/os-include -noixemul -fstrict-aliasing -fexpensive-optimizations" CFLAGS="$CFLAGS -mcpu=604 -fno-inline -mstring -mmultiple" + LDFLAGS="$LDFLAGS -noixemul" fi CFLAGS="$CFLAGS -O2 -fomit-frame-pointer" @@ -1138,12 +1148,51 @@ log 1 "checking makedepend... $makedepend" } +detect_awk() { + # Not all awks allow gsub(), so we test for that here! It is in fact all we need... + + # These awks are known to work. Test for them explicit + awks="gawk mawk nawk" + + awk_prefix="echo \"a.c b.c c.c\" | tr ' ' \\\\n | " + awk_param="' { ORS = \" \" } /\.c$/ { gsub(\".c$\", \".o\", \$0); print \$0; }' 2>/dev/null" + awk_result="a.o b.o c.o " + log 2 "Detecing awk..." + + log 2 "Trying: $awk_prefix $awk $awk_param" + res=`eval $awk_prefix $awk $awk_param` + log 2 "Result: '$res'" + if [ "$res" != "$awk_result" ] && [ "$awk" = "awk" ]; then + # User didn't supply his own awk, so try to detect some other known working names for an awk + for awk in $awks; do + log 2 "Trying: $awk_prefix $awk $awk_param" + res=`eval $awk_prefix $awk $awk_param` + log 2 "Result: '$res'" + if [ "$res" = "$awk_result" ]; then break; fi + done + + if [ "$res" != "$awk_result" ]; then + log 1 "checking awk... not found" + log 1 "configure: error: no awk found" + log 1 "configure: error: please install one of the following: $awks" + exit 1 + fi + fi + if [ "$res" != "$awk_result" ]; then + log 1 "checking awk... not found" + log 1 "configure: error: you supplied '$awk' but it doesn't seem a valid gawk or mawk" + exit 1 + fi + + log 1 "checking awk... $awk" +} + detect_os() { - if [ $os = "DETECT" ]; then + if [ "$os" = "DETECT" ]; then # Detect UNIX, OSX, FREEBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, WINCE, and PSP # Try first via dumpmachine, then via uname - os=`echo "$host" | tr [:upper:] [:lower:] | awk ' + os=`echo "$host" | tr '[A-Z]' '[a-z]' | $awk ' /linux/ { print "UNIX"; exit} /darwin/ { print "OSX"; exit} /freebsd/ { print "FREEBSD"; exit} @@ -1158,7 +1207,7 @@ '` if [ -z "$os" ]; then - os=`LC_ALL=C uname | tr [:upper:] [:lower:] | awk ' + os=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | $awk ' /linux/ { print "UNIX"; exit} /darwin/ { print "OSX"; exit} /freebsd/ { print "FREEBSD"; exit} @@ -1753,6 +1802,7 @@ s#!!OS!!#$os#g; s#!!CONFIGURE_FILES!!#$CONFIGURE_FILES#g; s#!!REVISION!!#$revision#g; + s#!!AWK!!#$awk#g; s#!!ENABLE_INSTALL!!#$enable_install#g; " } @@ -1849,6 +1899,7 @@ echo " on HOST [BUILD]" echo " --windres=WINDRES the windres to use [HOST-windres]" echo " --strip=STRIP the strip to use [HOST-strip]" + echo " --awk=AWK the awk to use in configure [awk]" echo " --lipo=LIPO the lipo to use (OSX ONLY) [HOST-lipo]" echo " --os=OS the OS we are compiling for [DETECT]" echo " DETECT/UNIX/OSX/FREEBSD/MORPHOS/BEOS/" diff -r 7c8ec33959b1 -r 4b5241e5dd10 configure --- a/configure Tue Feb 27 23:54:28 2007 +0000 +++ b/configure Wed Feb 28 00:33:40 2007 +0000 @@ -58,7 +58,7 @@ fi # Read the source.list and process it -SRCS="`< $ROOT_DIR/source.list tr '\r' '\n' | awk ' +SRCS="`< $ROOT_DIR/source.list tr '\r' '\n' | $awk ' { } /^( *)#end/ { if (deep == skip) { skip -= 1; } deep -= 1; next; } /^( *)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; } @@ -100,11 +100,11 @@ } ' | $PIPE_SORT`" -OBJS_C="` echo \"$SRCS\" | awk ' { ORS = " " } /\.c$/ { gsub(".c$", ".o", $0); print $0; }'`" -OBJS_CPP="`echo \"$SRCS\" | awk ' { ORS = " " } /\.cpp$/ { gsub(".cpp$", ".o", $0); print $0; }'`" -OBJS_MM="` echo \"$SRCS\" | awk ' { ORS = " " } /\.mm$/ { gsub(".mm$", ".o", $0); print $0; }'`" -OBJS_RC="` echo \"$SRCS\" | awk ' { ORS = " " } /\.rc$/ { gsub(".rc$", ".o", $0); print $0; }'`" -SRCS="` echo \"$SRCS\" | awk ' { ORS = " " } { print $0; }'`" +OBJS_C="` echo \"$SRCS\" | $awk ' { ORS = " " } /\.c$/ { gsub(".c$", ".o", $0); print $0; }'`" +OBJS_CPP="`echo \"$SRCS\" | $awk ' { ORS = " " } /\.cpp$/ { gsub(".cpp$", ".o", $0); print $0; }'`" +OBJS_MM="` echo \"$SRCS\" | $awk ' { ORS = " " } /\.mm$/ { gsub(".mm$", ".o", $0); print $0; }'`" +OBJS_RC="` echo \"$SRCS\" | $awk ' { ORS = " " } /\.rc$/ { gsub(".rc$", ".o", $0); print $0; }'`" +SRCS="` echo \"$SRCS\" | $awk ' { ORS = " " } { print $0; }'`" # In makefiles, we always use -u for sort if [ -z "$sort" ]; then diff -r 7c8ec33959b1 -r 4b5241e5dd10 docs/landscape.html --- a/docs/landscape.html Tue Feb 27 23:54:28 2007 +0000 +++ b/docs/landscape.html Wed Feb 28 00:33:40 2007 +0000 @@ -488,6 +488,7 @@
  • m3 bits 0..3: track type for railway stations, must be 0 for all the other stations
  • m3 bits 4..7: persistent random data for newstations
  • m4: custom station id; 0 means standard graphics
  • +
  • m6 bit 3: 1 when a drive through road stop is built over a town owned road, otherwise 0
  • diff -r 7c8ec33959b1 -r 4b5241e5dd10 docs/landscape_grid.html --- a/docs/landscape_grid.html Tue Feb 27 23:54:28 2007 +0000 +++ b/docs/landscape_grid.html Wed Feb 28 00:33:40 2007 +0000 @@ -171,7 +171,7 @@ XXXX XXXX XXXX XXXX XXXX XXXX - OOOO OOXX + OOOO OXXX 6 diff -r 7c8ec33959b1 -r 4b5241e5dd10 projects/generate --- a/projects/generate Tue Feb 27 23:54:28 2007 +0000 +++ b/projects/generate Wed Feb 28 00:33:40 2007 +0000 @@ -111,8 +111,7 @@ i=`basename $i | sed s/.txt$//g` RES="$RES + RelativePath=\"..\\src\\lang\\"$i".txt\"> + Outputs=\"..\\bin\\lang\\"$i".lng\"/> " done @@ -141,7 +139,15 @@ ' > \"$ROOT_DIR/projects/$2\"`" # The files-list - echo "$1" >> "$ROOT_DIR/projects/$2" + if [ "$3" = "msvc2003" ]; then + echo "$1" | sed 's@\ \ @\n@' >> "$ROOT_DIR/projects/$2" + else + echo "$1" | sed ' + s@Filter="">@>@; + s@^\([ ]*\)\([^ <].*[^/]\)>$@\1\2\n\1>@g; + s@^ \([ ]*\)\([^ <].*\)/>$@ \1\2\n\1/>@g; + ' >> "$ROOT_DIR/projects/$2" + fi # Everything below the !!FILES!! marker RES="`cat \"$ROOT_DIR/projects/$2\".in | tr '\r' '\n' | awk ' @@ -158,7 +164,7 @@ load_main_data "$ROOT_DIR/source.list" openttd load_lang_data "$ROOT_DIR/src/lang/*.txt" lang -generate "$openttd" "openttd.vcproj" -generate "$openttd" "openttd_vs80.vcproj" -generate "$lang" "langs_vs80.vcproj" -generate "$lang" "langs.vcproj" +generate "$openttd" "openttd.vcproj" "msvc2003" +generate "$openttd" "openttd_vs80.vcproj" "msvc2005" +generate "$lang" "langs.vcproj" "msvc2003" +generate "$lang" "langs_vs80.vcproj" "msvc2005" diff -r 7c8ec33959b1 -r 4b5241e5dd10 projects/langs.vcproj --- a/projects/langs.vcproj Tue Feb 27 23:54:28 2007 +0000 +++ b/projects/langs.vcproj Wed Feb 28 00:33:40 2007 +0000 @@ -39,493 +39,423 @@ + RelativePath="..\src\lang\american.txt"> + Outputs="..\bin\lang\american.lng"/> + RelativePath="..\src\lang\brazilian_portuguese.txt"> + Outputs="..\bin\lang\brazilian_portuguese.lng"/> + RelativePath="..\src\lang\bulgarian.txt"> + Outputs="..\bin\lang\bulgarian.lng"/> + RelativePath="..\src\lang\catalan.txt"> + Outputs="..\bin\lang\catalan.lng"/> + RelativePath="..\src\lang\czech.txt"> + Outputs="..\bin\lang\czech.lng"/> + RelativePath="..\src\lang\danish.txt"> + Outputs="..\bin\lang\danish.lng"/> + RelativePath="..\src\lang\dutch.txt"> + Outputs="..\bin\lang\dutch.lng"/> + RelativePath="..\src\lang\english.txt"> + Outputs="..\bin\lang\english.lng"/> + RelativePath="..\src\lang\esperanto.txt"> + Outputs="..\bin\lang\esperanto.lng"/> + RelativePath="..\src\lang\estonian.txt"> + Outputs="..\bin\lang\estonian.lng"/> + RelativePath="..\src\lang\finnish.txt"> + Outputs="..\bin\lang\finnish.lng"/> + RelativePath="..\src\lang\french.txt"> + Outputs="..\bin\lang\french.lng"/> + RelativePath="..\src\lang\galician.txt"> + Outputs="..\bin\lang\galician.lng"/> + RelativePath="..\src\lang\german.txt"> + Outputs="..\bin\lang\german.lng"/> + RelativePath="..\src\lang\hungarian.txt"> + Outputs="..\bin\lang\hungarian.lng"/> + RelativePath="..\src\lang\icelandic.txt"> + Outputs="..\bin\lang\icelandic.lng"/> + RelativePath="..\src\lang\italian.txt"> + Outputs="..\bin\lang\italian.lng"/> + RelativePath="..\src\lang\japanese.txt"> + Outputs="..\bin\lang\japanese.lng"/> + RelativePath="..\src\lang\korean.txt"> + Outputs="..\bin\lang\korean.lng"/> + RelativePath="..\src\lang\lithuanian.txt"> + Outputs="..\bin\lang\lithuanian.lng"/> + RelativePath="..\src\lang\norwegian_bokmal.txt"> + Outputs="..\bin\lang\norwegian_bokmal.lng"/> + RelativePath="..\src\lang\norwegian_nynorsk.txt"> + Outputs="..\bin\lang\norwegian_nynorsk.lng"/> + RelativePath="..\src\lang\origveh.txt"> + Outputs="..\bin\lang\origveh.lng"/> + RelativePath="..\src\lang\polish.txt"> + Outputs="..\bin\lang\polish.lng"/> + RelativePath="..\src\lang\portuguese.txt"> + Outputs="..\bin\lang\portuguese.lng"/> + RelativePath="..\src\lang\romanian.txt"> + Outputs="..\bin\lang\romanian.lng"/> + RelativePath="..\src\lang\russian.txt"> + Outputs="..\bin\lang\russian.lng"/> + RelativePath="..\src\lang\simplified_chinese.txt"> + Outputs="..\bin\lang\simplified_chinese.lng"/> + RelativePath="..\src\lang\slovak.txt"> + Outputs="..\bin\lang\slovak.lng"/> + RelativePath="..\src\lang\slovenian.txt"> + Outputs="..\bin\lang\slovenian.lng"/> + RelativePath="..\src\lang\spanish.txt"> + Outputs="..\bin\lang\spanish.lng"/> + RelativePath="..\src\lang\swedish.txt"> + Outputs="..\bin\lang\swedish.lng"/> + RelativePath="..\src\lang\traditional_chinese.txt"> + Outputs="..\bin\lang\traditional_chinese.lng"/> + RelativePath="..\src\lang\turkish.txt"> + Outputs="..\bin\lang\turkish.lng"/> + RelativePath="..\src\lang\ukrainian.txt"> + Outputs="..\bin\lang\ukrainian.lng"/> diff -r 7c8ec33959b1 -r 4b5241e5dd10 projects/langs_vs80.vcproj --- a/projects/langs_vs80.vcproj Tue Feb 27 23:54:28 2007 +0000 +++ b/projects/langs_vs80.vcproj Wed Feb 28 00:33:40 2007 +0000 @@ -25,6 +25,11 @@ ATLMinimizesCRunTimeLibraryUsage="false" > + - @@ -47,493 +47,423 @@ + RelativePath="..\src\lang\american.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\american.lng"n /> + RelativePath="..\src\lang\brazilian_portuguese.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\brazilian_portuguese.lng"n /> + RelativePath="..\src\lang\bulgarian.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\bulgarian.lng"n /> + RelativePath="..\src\lang\catalan.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\catalan.lng"n /> + RelativePath="..\src\lang\czech.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\czech.lng"n /> + RelativePath="..\src\lang\danish.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\danish.lng"n /> + RelativePath="..\src\lang\dutch.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\dutch.lng"n /> + RelativePath="..\src\lang\english.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\english.lng"n /> + RelativePath="..\src\lang\esperanto.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\esperanto.lng"n /> + RelativePath="..\src\lang\estonian.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\estonian.lng"n /> + RelativePath="..\src\lang\finnish.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\finnish.lng"n /> + RelativePath="..\src\lang\french.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\french.lng"n /> + RelativePath="..\src\lang\galician.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\galician.lng"n /> + RelativePath="..\src\lang\german.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\german.lng"n /> + RelativePath="..\src\lang\hungarian.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\hungarian.lng"n /> + RelativePath="..\src\lang\icelandic.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\icelandic.lng"n /> + RelativePath="..\src\lang\italian.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\italian.lng"n /> + RelativePath="..\src\lang\japanese.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\japanese.lng"n /> + RelativePath="..\src\lang\korean.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\korean.lng"n /> + RelativePath="..\src\lang\lithuanian.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\lithuanian.lng"n /> + RelativePath="..\src\lang\norwegian_bokmal.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\norwegian_bokmal.lng"n /> + RelativePath="..\src\lang\norwegian_nynorsk.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\norwegian_nynorsk.lng"n /> + RelativePath="..\src\lang\origveh.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\origveh.lng"n /> + RelativePath="..\src\lang\polish.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\polish.lng"n /> + RelativePath="..\src\lang\portuguese.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\portuguese.lng"n /> + RelativePath="..\src\lang\romanian.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\romanian.lng"n /> + RelativePath="..\src\lang\russian.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\russian.lng"n /> + RelativePath="..\src\lang\simplified_chinese.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\simplified_chinese.lng"n /> + RelativePath="..\src\lang\slovak.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\slovak.lng"n /> + RelativePath="..\src\lang\slovenian.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\slovenian.lng"n /> + RelativePath="..\src\lang\spanish.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\spanish.lng"n /> + RelativePath="..\src\lang\swedish.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\swedish.lng"n /> + RelativePath="..\src\lang\traditional_chinese.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\traditional_chinese.lng"n /> + RelativePath="..\src\lang\turkish.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\turkish.lng"n /> + RelativePath="..\src\lang\ukrainian.txt"n > + Name="Debug|Win32"n > + Outputs="..\bin\lang\ukrainian.lng"n /> diff -r 7c8ec33959b1 -r 4b5241e5dd10 projects/langs_vs80.vcproj.in --- a/projects/langs_vs80.vcproj.in Tue Feb 27 23:54:28 2007 +0000 +++ b/projects/langs_vs80.vcproj.in Wed Feb 28 00:33:40 2007 +0000 @@ -25,6 +25,11 @@ ATLMinimizesCRunTimeLibraryUsage="false" > + - diff -r 7c8ec33959b1 -r 4b5241e5dd10 projects/openttd.sln --- a/projects/openttd.sln Tue Feb 27 23:54:28 2007 +0000 +++ b/projects/openttd.sln Wed Feb 28 00:33:40 2007 +0000 @@ -19,17 +19,15 @@ Debug = Debug Release = Release EndGlobalSection - GlobalSection(ProjectDependencies) = postSolution - EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution + {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug.ActiveCfg = Debug|Win32 + {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug.Build.0 = Debug|Win32 + {668328A0-B40E-4CDB-BD72-D0064424414A}.Release.ActiveCfg = Release|Win32 + {668328A0-B40E-4CDB-BD72-D0064424414A}.Release.Build.0 = Release|Win32 {A133A442-BD0A-4ADE-B117-AD7545E4BDD1}.Debug.ActiveCfg = Release|Win32 {A133A442-BD0A-4ADE-B117-AD7545E4BDD1}.Debug.Build.0 = Release|Win32 {A133A442-BD0A-4ADE-B117-AD7545E4BDD1}.Release.ActiveCfg = Release|Win32 {A133A442-BD0A-4ADE-B117-AD7545E4BDD1}.Release.Build.0 = Release|Win32 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug.ActiveCfg = Debug|Win32 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug.Build.0 = Debug|Win32 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Release.ActiveCfg = Release|Win32 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Release.Build.0 = Release|Win32 {0F066B23-18DF-4284-8265-F4A5E7E3B966}.Debug.ActiveCfg = Debug|Win32 {0F066B23-18DF-4284-8265-F4A5E7E3B966}.Debug.Build.0 = Debug|Win32 {0F066B23-18DF-4284-8265-F4A5E7E3B966}.Release.ActiveCfg = Debug|Win32 diff -r 7c8ec33959b1 -r 4b5241e5dd10 projects/openttd.vcproj --- a/projects/openttd.vcproj Tue Feb 27 23:54:28 2007 +0000 +++ b/projects/openttd.vcproj Wed Feb 28 00:33:40 2007 +0000 @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="7.10" Name="openttd" - RootNameSpace="openttd" + RootNamespace="openttd" SccProjectName="" SccLocalPath=""> @@ -173,6 +173,9 @@ RelativePath=".\..\src\callback_table.cpp"> + + - - - - - - - - + + - - + + - - - - - - - - - - - - - - + + - - + RelativePath=".\..\src\ai\trolly\build.cpp"> + RelativePath=".\..\src\ai\default\default.cpp"> @@ -941,9 +914,6 @@ RelativePath=".\..\src\newgrf.cpp"> - - + + + + + + + + + + + + + + + + + + + + + + + + diff -r 7c8ec33959b1 -r 4b5241e5dd10 projects/openttd_vs80.sln --- a/projects/openttd_vs80.sln Tue Feb 27 23:54:28 2007 +0000 +++ b/projects/openttd_vs80.sln Wed Feb 28 00:33:40 2007 +0000 @@ -21,6 +21,14 @@ Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug|Win32.ActiveCfg = Debug|Win32 + {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug|Win32.Build.0 = Debug|Win32 + {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug|x64.ActiveCfg = Debug|x64 + {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug|x64.Build.0 = Debug|x64 + {668328A0-B40E-4CDB-BD72-D0064424414A}.Release|Win32.ActiveCfg = Release|Win32 + {668328A0-B40E-4CDB-BD72-D0064424414A}.Release|Win32.Build.0 = Release|Win32 + {668328A0-B40E-4CDB-BD72-D0064424414A}.Release|x64.ActiveCfg = Release|x64 + {668328A0-B40E-4CDB-BD72-D0064424414A}.Release|x64.Build.0 = Release|x64 {A133A442-BD0A-4ADE-B117-AD7545E4BDD1}.Debug|Win32.ActiveCfg = Debug|Win32 {A133A442-BD0A-4ADE-B117-AD7545E4BDD1}.Debug|Win32.Build.0 = Debug|Win32 {A133A442-BD0A-4ADE-B117-AD7545E4BDD1}.Debug|x64.ActiveCfg = Debug|Win32 @@ -29,14 +37,6 @@ {A133A442-BD0A-4ADE-B117-AD7545E4BDD1}.Release|Win32.Build.0 = Debug|Win32 {A133A442-BD0A-4ADE-B117-AD7545E4BDD1}.Release|x64.ActiveCfg = Debug|Win32 {A133A442-BD0A-4ADE-B117-AD7545E4BDD1}.Release|x64.Build.0 = Debug|Win32 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug|Win32.ActiveCfg = Debug|Win32 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug|Win32.Build.0 = Debug|Win32 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug|x64.ActiveCfg = Debug|x64 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Debug|x64.Build.0 = Debug|x64 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Release|Win32.ActiveCfg = Release|Win32 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Release|Win32.Build.0 = Release|Win32 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Release|x64.ActiveCfg = Release|x64 - {668328A0-B40E-4CDB-BD72-D0064424414A}.Release|x64.Build.0 = Release|x64 {0F066B23-18DF-4284-8265-F4A5E7E3B966}.Debug|Win32.ActiveCfg = Debug|Win32 {0F066B23-18DF-4284-8265-F4A5E7E3B966}.Debug|Win32.Build.0 = Debug|Win32 {0F066B23-18DF-4284-8265-F4A5E7E3B966}.Debug|x64.ActiveCfg = Debug|Win32 diff -r 7c8ec33959b1 -r 4b5241e5dd10 projects/openttd_vs80.vcproj --- a/projects/openttd_vs80.vcproj Tue Feb 27 23:54:28 2007 +0000 +++ b/projects/openttd_vs80.vcproj Wed Feb 28 00:33:40 2007 +0000 @@ -442,1069 +442,1076 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + RelativePath=".\..\src\airport.cpp"n > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + RelativePath=".\..\src\aystar.cpp"n > - - - - - - - - - - - - - - - - + RelativePath=".\..\src\bmp.cpp"n > - - - - - - - - + RelativePath=".\..\src\callback_table.cpp"n > - - + RelativePath=".\..\src\cargotype.cpp"n > + RelativePath=".\..\src\command.cpp"n > + RelativePath=".\..\src\console.cpp"n > + RelativePath=".\..\src\console_cmds.cpp"n > + RelativePath=".\..\src\currency.cpp"n > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + RelativePath=".\..\src\aircraft.h"n > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + RelativePath=".\..\src\airport.h"n > - - - - - - - - - - - - - - - - - - - - - - + RelativePath=".\..\src\airport_movement.h"n > - - - - - - - - - - + RelativePath=".\..\src\aystar.h"n > - - - - + RelativePath=".\..\src\bmp.h"n > + RelativePath=".\..\src\cargotype.h"n > + RelativePath=".\..\src\command.h"n > + RelativePath=".\..\src\console.h"n > + RelativePath=".\..\src\currency.h"n > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + > - - - - - - - - - - - - - - - - + RelativePath=".\..\src\aircraft_gui.cpp"n > - - - - - - - - - - - - - - + RelativePath=".\..\src\airport_gui.cpp"n > - - - - - - + RelativePath=".\..\src\autoreplace_gui.cpp"n > - - + RelativePath=".\..\src\bridge_gui.cpp"n > + RelativePath=".\..\src\build_vehicle_gui.cpp"n > + RelativePath=".\..\src\depot_gui.cpp"n > + RelativePath=".\..\src\dock_gui.cpp"n > + RelativePath=".\..\src\engine_gui.cpp"n > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + > - - - - - - - - + RelativePath=".\..\src\aircraft_cmd.cpp"n > - - - - - - + RelativePath=".\..\src\clear_cmd.cpp"n > - - + RelativePath=".\..\src\disaster_cmd.cpp"n > + RelativePath=".\..\src\dummy_land.cpp"n > + RelativePath=".\..\src\industry_cmd.cpp"n > + RelativePath=".\..\src\misc_cmd.cpp"n > + RelativePath=".\..\src\order_cmd.cpp"n > + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + > - - - - - - - - - - - - + RelativePath=".\..\src\table\ai_rail.h"n > - - - - - - - - - - + RelativePath=".\..\src\table\allstrings.h"n > - - - - + RelativePath=".\..\src\table\animcursors.h"n > - - + RelativePath=".\..\src\table\autorail.h"n > + RelativePath=".\..\src\table\build_industry.h"n > + RelativePath=".\..\src\table\cargo_const.h"n > + RelativePath=".\..\src\table\clear_land.h"n > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > - - + RelativePath=".\..\src\ai\ai.cpp"n > + RelativePath=".\..\src\ai\trolly\build.cpp"n > + RelativePath=".\..\src\ai\default\default.cpp"n > + RelativePath=".\..\src\ai\trolly\pathfinder.cpp"n > + RelativePath=".\..\src\ai\trolly\shared.cpp"n > + + + > - - - - + RelativePath=".\..\src\newgrf.cpp"n > - - + RelativePath=".\..\src\newgrf_config.cpp"n > + RelativePath=".\..\src\newgrf_engine.cpp"n > + RelativePath=".\..\src\newgrf_sound.cpp"n > + RelativePath=".\..\src\newgrf_spritegroup.cpp"n > + + + + - - - - + > - - - - - - - - + RelativePath=".\..\src\bridge_map.cpp"n > - - - - - - + RelativePath=".\..\src\bridge_map.h"n > - - + RelativePath=".\..\src\clear_map.h"n > + RelativePath=".\..\src\industry_map.h"n > + RelativePath=".\..\src\rail_map.h"n > + RelativePath=".\..\src\road_map.cpp"n > + + + + + + + + + + + + + + + + + + + + - - + > - - - - + RelativePath=".\..\src\misc\array.hpp"n > - - - - + RelativePath=".\..\src\misc\autocopyptr.hpp"n > + RelativePath=".\..\src\misc\autoptr.hpp"n > + RelativePath=".\..\src\misc\binaryheap.hpp"n > + RelativePath=".\..\src\misc\blob.hpp"n > + RelativePath=".\..\src\misc\countedobj.cpp"n > + + + + + + + + + + - - - - - - + > - - - - - - - - - - + RelativePath=".\..\src\widget\widget.h"n > - - - - - - - - + RelativePath=".\..\src\widget\widget_base.cpp"n > - - - - + RelativePath=".\..\src\widget\widget_button.cpp"n > + RelativePath=".\..\src\widget\widget_button_img2.cpp"n > + RelativePath=".\..\src\widget\widget_button_img.cpp"n > + RelativePath=".\..\src\widget\widget_button_txt2.cpp"n > + RelativePath=".\..\src\widget\widget_button_txt.cpp"n > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + > - - - - - - - - - - + RelativePath=".\..\src\yapf\follow_track.cpp"n > - - - - - - - - + RelativePath=".\..\src\yapf\follow_track.hpp"n > - - + RelativePath=".\..\src\yapf\nodelist.hpp"n > + RelativePath=".\..\src\yapf\track_dir.hpp"n > + RelativePath=".\..\src\yapf\yapf.h"n > + RelativePath=".\..\src\yapf\yapf.hpp"n > + RelativePath=".\..\src\yapf\yapf_base.hpp"n > + + + + + + + + + + + + + + + + + + + + + + + + + + + > + RelativePath=".\..\src\video\dedicated_v.cpp"n > + RelativePath=".\..\src\video\null_v.cpp"n > + RelativePath=".\..\src\video\sdl_v.cpp"n > + RelativePath=".\..\src\video\win32_v.cpp"n > + > + RelativePath=".\..\src\music\dmusic.cpp"n > + RelativePath=".\..\src\music\null_m.cpp"n > + RelativePath=".\..\src\music\win32_m.cpp"n > + > + RelativePath=".\..\src\sound\null_s.cpp"n > + RelativePath=".\..\src\sound\sdl_s.cpp"n > + RelativePath=".\..\src\sound\win32_s.cpp"n > + RelativePath=".\..\media\mainicon.ico" + > + RelativePath=".\..\media\openttd.ico" + > + RelativePath=".\..\readme.txt" + > diff -r 7c8ec33959b1 -r 4b5241e5dd10 projects/openttd_vs80.vcproj.in --- a/projects/openttd_vs80.vcproj.in Tue Feb 27 23:54:28 2007 +0000 +++ b/projects/openttd_vs80.vcproj.in Wed Feb 28 00:33:40 2007 +0000 @@ -485,13 +485,16 @@ + RelativePath=".\..\media\mainicon.ico" + > + RelativePath=".\..\media\openttd.ico" + > + RelativePath=".\..\readme.txt" + > diff -r 7c8ec33959b1 -r 4b5241e5dd10 projects/strgen_vs80.vcproj --- a/projects/strgen_vs80.vcproj Tue Feb 27 23:54:28 2007 +0000 +++ b/projects/strgen_vs80.vcproj Wed Feb 28 00:33:40 2007 +0000 @@ -44,7 +44,6 @@ + Name="Release|Win32" + > - - + ObjectFile="$(IntDir)/$(InputName)1.obj" + /> + + attr, 1, 3); h = GB(p->attr, 4, 3); - if (p->attr & 1) uintswap(w, h); + if (p->attr & 1) Swap(w, h); if (cargo & 0x80) { GetProductionAroundTiles(values, tile2, w, h, rad); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/aircraft.h --- a/src/aircraft.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/aircraft.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file aircraft.h */ + #ifndef AIRCRAFT_H #define AIRCRAFT_H @@ -40,11 +42,13 @@ return IsAircraftInHangar(v) && v->vehstatus & VS_STOPPED; } -uint16 AircraftDefaultCargoCapacity(CargoID cid, EngineID engine_type); +uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo*); void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2); void CcCloneAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2); void HandleAircraftEnterHangar(Vehicle *v); void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height); +void UpdateAirplanesOnNewStation(const Station *st); + #endif /* AIRCRAFT_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/aircraft_cmd.cpp --- a/src/aircraft_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/aircraft_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,8 @@ /* $Id$ */ +/** @file aircraft_cmd.cpp + * This file deals with aircraft and airport movements functionalities */ + #include "stdafx.h" #include "openttd.h" #include "aircraft.h" @@ -28,17 +31,16 @@ #include "date.h" #include "spritecache.h" -// this maps the terminal to its corresponding state and block flag -// currently set for 10 terms, 4 helipads +/** this maps the terminal to its corresponding state and block flag + * currently set for 10 terms, 4 helipads */ static const byte _airport_terminal_state[] = {2, 3, 4, 5, 6, 7, 19, 20, 0, 0, 8, 9, 21, 22}; static const byte _airport_terminal_flag[] = {0, 1, 2, 3, 4, 5, 22, 23, 0, 0, 6, 7, 24, 25}; static bool AirportMove(Vehicle *v, const AirportFTAClass *apc); -static bool AirportSetBlocks(Vehicle *v, AirportFTA *current_pos, const AirportFTAClass *apc); +static bool AirportSetBlocks(Vehicle *v, const AirportFTA *current_pos, const AirportFTAClass *apc); static bool AirportHasBlock(Vehicle *v, const AirportFTA *current_pos, const AirportFTAClass *apc); static bool AirportFindFreeTerminal(Vehicle *v, const AirportFTAClass *apc); static bool AirportFindFreeHelipad(Vehicle *v, const AirportFTAClass *apc); -static void AirportGoToNextPosition(Vehicle *v, const AirportFTAClass *apc); static void CrashAirplane(Vehicle *v); static void AircraftNextAirportPos_and_Order(Vehicle *v); @@ -54,7 +56,7 @@ 0x0EBD, 0x0EC5 }; -/* Helicopter rotor animation states */ +/** Helicopter rotor animation states */ enum HelicopterRotorStates { HRS_ROTOR_STOPPED, HRS_ROTOR_MOVING_1, @@ -62,9 +64,11 @@ HRS_ROTOR_MOVING_3, }; -/* Find the nearest hangar to v +/** Find the nearest hangar to v * INVALID_STATION is returned, if the player does not have any suitable * airports (like helipads only) + * @param v vehicle looking for a hangar + * @return the StationID if one is found, otherwise, INVALID_STATION */ static StationID FindNearestHangar(const Vehicle *v) { @@ -86,7 +90,7 @@ continue; } - // v->tile can't be used here, when aircraft is flying v->tile is set to 0 + /* v->tile can't be used here, when aircraft is flying v->tile is set to 0 */ uint distance = DistanceSquare(vtile, st->airport_tile); if (distance < best || index == INVALID_STATION) { best = distance; @@ -97,7 +101,9 @@ } #if 0 -// returns true if vehicle v have an airport in the schedule, that has a hangar +/** Check if given vehicle has a goto hangar in his orders + * @param v vehicle to inquiry + * @return true if vehicle v has an airport in the schedule, that has a hangar */ static bool HaveHangarInOrderList(Vehicle *v) { const Order *order; @@ -105,7 +111,7 @@ FOR_VEHICLE_ORDERS(v, order) { const Station *st = GetStation(order->station); if (st->owner == v->owner && st->facilities & FACIL_AIRPORT) { - // If an airport doesn't have a hangar, skip it + /* If an airport doesn't have a hangar, skip it */ if (st->Airport()->nof_depots != 0) return true; } @@ -130,11 +136,9 @@ SpriteID GetRotorImage(const Vehicle *v) { - const Vehicle *w; - assert(v->subtype == AIR_HELICOPTER); - w = v->next->next; + const Vehicle *w = v->next->next; if (is_custom_sprite(v->spritenum)) { SpriteID spritenum = GetCustomRotorSprite(v, false); if (spritenum != 0) return spritenum; @@ -205,10 +209,8 @@ * @param engine Which engine to find a cargo capacity for. * @return New cargo capacity value. */ -uint16 AircraftDefaultCargoCapacity(CargoID cid, EngineID engine_type) +uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi) { - const AircraftVehicleInfo *avi = AircraftVehInfo(engine_type); - assert(cid != CT_INVALID); /* An aircraft can carry twice as much goods as normal cargo, @@ -228,27 +230,26 @@ /** Build an aircraft. * @param tile tile of depot where aircraft is built + * @param flags for command * @param p1 aircraft type being built (engine) * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number + * return result of operation. Could be cost, error */ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Vehicle *vl[3]; - UnitID unit_num; - if (!IsEngineBuildable(p1, VEH_Aircraft, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE); const AircraftVehicleInfo *avi = AircraftVehInfo(p1); int32 value = EstimateAircraftCost(avi); - // to just query the cost, it is not neccessary to have a valid tile (automation/AI) + /* to just query the cost, it is not neccessary to have a valid tile (automation/AI) */ if (flags & DC_QUERY_COST) return value; 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 + /* Prevent building aircraft types at places which can't handle them */ const Station* st = GetStationByTile(tile); const AirportFTAClass* apc = st->Airport(); if (!(apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS))) { @@ -257,19 +258,16 @@ /* Allocate 2 or 3 vehicle structs, depending on type * vl[0] = aircraft, vl[1] = shadow, [vl[2] = rotor] */ + Vehicle *vl[3]; if (!AllocateVehicles(vl, avi->subtype & AIR_CTOL ? 2 : 3)) { return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); } - unit_num = HASBIT(p2, 0) ? 0 : GetFreeUnitNumber(VEH_Aircraft); + UnitID unit_num = HASBIT(p2, 0) ? 0 : GetFreeUnitNumber(VEH_Aircraft); if (unit_num > _patches.max_aircraft) return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); if (flags & DC_EXEC) { - CargoID cargo; - uint x; - uint y; - Vehicle *v = vl[0]; // aircraft Vehicle *u = vl[1]; // shadow @@ -282,8 +280,8 @@ v->tile = tile; // u->tile = 0; - x = TileX(tile) * TILE_SIZE + 5; - y = TileY(tile) * TILE_SIZE + 3; + uint x = TileX(tile) * TILE_SIZE + 5; + uint y = TileY(tile) * TILE_SIZE + 3; v->x_pos = u->x_pos = x; v->y_pos = u->y_pos = y; @@ -336,7 +334,7 @@ * passengers, we select the cargo type from the refit mask. * This is a fairly nasty hack to get around the fact that TTD * has no default cargo type specifier for planes... */ - cargo = FindFirstRefittableCargo(p1); + CargoID cargo = FindFirstRefittableCargo(p1); if (cargo != CT_INVALID && cargo != CT_PASSENGERS) { uint16 callback = CALLBACK_FAILED; @@ -348,7 +346,7 @@ if (callback == CALLBACK_FAILED) { /* Callback failed, or not executed; use the default cargo capacity */ - v->cargo_cap = AircraftDefaultCargoCapacity(v->cargo_type, v->engine_type); + v->cargo_cap = AircraftDefaultCargoCapacity(v->cargo_type, avi); } else { v->cargo_cap = callback; } @@ -395,7 +393,7 @@ VehiclePositionChanged(v); VehiclePositionChanged(u); - // Aircraft with 3 vehicles (chopper)? + /* Aircraft with 3 vehicles (chopper)? */ if (v->subtype == AIR_HELICOPTER) { Vehicle *w = vl[2]; @@ -445,16 +443,16 @@ /** Sell an aircraft. * @param tile unused + * @param flags for command type * @param p1 vehicle ID to be sold * @param p2 unused + * @return result of operation. Error or sold value */ int32 CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Vehicle *v; - if (!IsValidVehicleID(p1)) return CMD_ERROR; - v = GetVehicle(p1); + Vehicle *v = GetVehicle(p1); if (v->type != VEH_Aircraft || !CheckOwnership(v->owner)) return CMD_ERROR; if (!IsAircraftInHangarStopped(v)) return_cmd_error(STR_A01B_AIRCRAFT_MUST_BE_STOPPED); @@ -472,27 +470,26 @@ /** Start/Stop an aircraft. * @param tile unused + * @param flags for command type * @param p1 aircraft ID to start/stop * @param p2 unused + * @return result of operation. Nothing if everything went well */ int32 CmdStartStopAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Vehicle *v; - uint16 callback; - if (!IsValidVehicleID(p1)) return CMD_ERROR; - v = GetVehicle(p1); + Vehicle *v = GetVehicle(p1); if (v->type != VEH_Aircraft || !CheckOwnership(v->owner)) return CMD_ERROR; - // cannot stop airplane when in flight, or when taking off / landing + /* cannot stop airplane when in flight, or when taking off / landing */ if (v->u.air.state >= STARTTAKEOFF && v->u.air.state < TERM7) return_cmd_error(STR_A017_AIRCRAFT_IS_IN_FLIGHT); /* Check if this aircraft can be started/stopped. The callback will fail or * return 0xFF if it can. */ - callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v); + uint16 callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v); if (callback != CALLBACK_FAILED && callback != 0xFF) { StringID error = GetGRFStringID(GetEngineGRFID(v->engine_type), 0xD000 + callback); return_cmd_error(error); @@ -514,15 +511,15 @@ /** Send an aircraft to the hangar. * @param tile unused + * @param flags for command type * @param p1 vehicle ID to send to the hangar * @param p2 various bitmasked elements * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h) * - p2 bit 8-10 - VLW flag (for mass goto depot) + * @return o if everything went well */ int32 CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Vehicle *v; - if (p2 & DEPOT_MASS_SEND) { /* Mass goto depot requested */ if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR; @@ -531,7 +528,7 @@ if (!IsValidVehicleID(p1)) return CMD_ERROR; - v = GetVehicle(p1); + Vehicle *v = GetVehicle(p1); if (v->type != VEH_Aircraft || !CheckOwnership(v->owner) || IsAircraftInHangar(v)) return CMD_ERROR; @@ -560,16 +557,12 @@ const Station *st = GetStation(next_airport_index); /* If the station is not a valid airport or if it has no hangars */ if (!st->IsValid() || st->airport_tile == 0 || st->Airport()->nof_depots == 0) { - StationID station; - - // the aircraft has to search for a hangar on its own - station = FindNearestHangar(v); + /* the aircraft has to search for a hangar on its own */ + StationID station = FindNearestHangar(v); next_airport_has_hangar = false; if (station == INVALID_STATION) return CMD_ERROR; - st = GetStation(station); next_airport_index = station; - } if (flags & DC_EXEC) { @@ -592,36 +585,32 @@ /** Refits an aircraft to the specified cargo type. * @param tile unused + * @param flags for command type * @param p1 vehicle ID of the aircraft to refit * @param p2 various bitstuffed elements * - p2 = (bit 0-7) - the new cargo type to refit to * - p2 = (bit 8-15) - the new cargo subtype to refit to + * @return cost of refit or error */ int32 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Vehicle *v; - int pass, mail; - int32 cost; - CargoID new_cid = GB(p2, 0, 8); byte new_subtype = GB(p2, 8, 8); - const AircraftVehicleInfo *avi; - uint16 callback = CALLBACK_FAILED; if (!IsValidVehicleID(p1)) return CMD_ERROR; - v = GetVehicle(p1); + Vehicle *v = GetVehicle(p1); if (v->type != VEH_Aircraft || !CheckOwnership(v->owner)) return CMD_ERROR; if (!IsAircraftInHangarStopped(v)) return_cmd_error(STR_A01B_AIRCRAFT_MUST_BE_STOPPED); - avi = AircraftVehInfo(v->engine_type); - /* 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_REFIT_CAPACITY)) { /* Back up the existing cargo type */ CargoID temp_cid = v->cargo_type; @@ -636,26 +625,28 @@ v->cargo_subtype = temp_subtype; } + const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type); + + uint pass; if (callback == CALLBACK_FAILED) { /* If the callback failed, or wasn't executed, use the aircraft's * default cargo capacity */ - pass = AircraftDefaultCargoCapacity(new_cid, v->engine_type); + pass = AircraftDefaultCargoCapacity(new_cid, avi); } else { pass = callback; } _returned_refit_capacity = pass; - cost = 0; + int32 cost = 0; if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) { cost = GetRefitCost(v->engine_type); } if (flags & DC_EXEC) { - Vehicle *u; v->cargo_cap = pass; - u = v->next; - mail = (new_cid != CT_PASSENGERS) ? 0 : avi->mail_capacity; + Vehicle *u = v->next; + uint mail = new_cid != CT_PASSENGERS ? 0 : avi->mail_capacity; u->cargo_cap = mail; if (v->cargo_type == new_cid) { v->cargo_count = min(pass, v->cargo_count); @@ -677,8 +668,6 @@ static void CheckIfAircraftNeedsService(Vehicle *v) { - const Station* st; - if (_patches.servint_aircraft == 0) return; if (!VehicleNeedsService(v)) return; if (v->vehstatus & VS_STOPPED) return; @@ -694,8 +683,8 @@ return; } - st = GetStation(v->current_order.dest); - // only goto depot if the target airport has terminals (eg. it is airport) + const Station *st = GetStation(v->current_order.dest); + /* only goto depot if the target airport has terminals (eg. it is airport) */ if (st->IsValid() && st->airport_tile != 0 && st->Airport()->terminals != NULL) { // printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index); // v->u.air.targetairport = st->index; @@ -711,8 +700,6 @@ void OnNewDay_Aircraft(Vehicle *v) { - int32 cost; - if (!IsNormalAircraft(v)) return; if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v); @@ -725,7 +712,7 @@ if (v->vehstatus & VS_STOPPED) return; - cost = AircraftVehInfo(v->engine_type)->running_cost * _price.aircraft_running / 364; + int32 cost = AircraftVehInfo(v->engine_type)->running_cost * _price.aircraft_running / 364; v->profit_this_year -= cost >> 8; @@ -761,16 +748,12 @@ static void HelicopterTickHandler(Vehicle *v) { - Vehicle *u; - int tick,spd; - SpriteID img; - - u = v->next->next; + Vehicle *u = v->next->next; if (u->vehstatus & VS_HIDDEN) return; - // if true, helicopter rotors do not rotate. This should only be the case if a helicopter is - // loading/unloading at a terminal or stopped + /* if true, helicopter rotors do not rotate. This should only be the case if a helicopter is + * loading/unloading at a terminal or stopped */ if (v->current_order.type == OT_LOADING || (v->vehstatus & VS_STOPPED)) { if (u->cur_speed != 0) { u->cur_speed++; @@ -786,9 +769,10 @@ u->cur_speed--; } - tick = ++u->tick_counter; - spd = u->cur_speed >> 4; + int tick = ++u->tick_counter; + int spd = u->cur_speed >> 4; + SpriteID img; if (spd == 0) { u->u.air.state = HRS_ROTOR_STOPPED; img = GetRotorImage(v); @@ -811,10 +795,6 @@ static void SetAircraftPosition(Vehicle *v, int x, int y, int z) { - Vehicle *u; - int safe_x; - int safe_y; - v->x_pos = x; v->y_pos = y; v->z_pos = z; @@ -826,10 +806,10 @@ VehiclePositionChanged(v); EndVehicleMove(v); - u = v->next; + Vehicle *u = v->next; - safe_x = clamp(x, 0, MapMaxX() * TILE_SIZE); - safe_y = clamp(y - 1, 0, MapMaxY() * TILE_SIZE); + int safe_x = clamp(x, 0, MapMaxX() * TILE_SIZE); + int safe_y = clamp(y - 1, 0, MapMaxY() * TILE_SIZE); u->x_pos = x; u->y_pos = y - ((v->z_pos-GetSlopeZ(safe_x, safe_y)) >> 3);; @@ -858,12 +838,10 @@ */ void HandleAircraftEnterHangar(Vehicle *v) { - Vehicle *u; - v->subspeed = 0; v->progress = 0; - u = v->next; + Vehicle *u = v->next; u->vehstatus |= VS_HIDDEN; u = u->next; if (u != NULL) { @@ -898,10 +876,10 @@ if (speed_limit == SPEED_LIMIT_NONE) speed_limit = v->max_speed; spd = min(v->cur_speed + (spd >> 8) + (v->subspeed < t), speed_limit); - // adjust speed for broken vehicles + /* adjust speed for broken vehicles */ if (v->vehstatus & VS_AIRCRAFT_BROKEN) spd = min(spd, SPEED_LIMIT_BROKEN); - //updates statusbar only if speed have changed to save CPU time + /* updates statusbar only if speed have changed to save CPU time */ if (spd != v->cur_speed) { v->cur_speed = spd; if (_patches.vehicle_speed) @@ -937,7 +915,13 @@ * other by providing them with vertical seperation */ switch (v->direction) { - case DIR_N: case DIR_NE: case DIR_E: case DIR_SE: base_altitude += 15; break; + case DIR_N: + case DIR_NE: + case DIR_E: + case DIR_SE: + base_altitude += 15; + break; + default: break; } @@ -949,35 +933,23 @@ static bool AircraftController(Vehicle *v) { - Station *st; - Vehicle *u; - byte z, maxz, curz; - Direction newdir; - GetNewVehiclePosResult gp; - uint dist; - int x,y; - - st = GetStation(v->u.air.targetairport); + const Station *st = GetStation(v->u.air.targetairport); - // prevent going to 0,0 if airport is deleted. - { - TileIndex tile = st->airport_tile; + /* prevent going to 0,0 if airport is deleted. */ + TileIndex tile = st->airport_tile; + if (tile == 0) tile = st->xy; + int x = TileX(tile) * TILE_SIZE; + int y = TileY(tile) * TILE_SIZE; - if (tile == 0) tile = st->xy; - // xy of destination - x = TileX(tile) * TILE_SIZE; - y = TileY(tile) * TILE_SIZE; - } - - // get airport moving data + /* get airport moving data */ const AirportFTAClass *afc = st->Airport(); const AirportMovingData *amd = afc->MovingData(v->u.air.pos); - // Helicopter raise + /* Helicopter raise */ if (amd->flag & AMED_HELI_RAISE) { - u = v->next->next; + Vehicle *u = v->next->next; - // Make sure the rotors don't rotate too fast + /* Make sure the rotors don't rotate too fast */ if (u->cur_speed > 32) { v->cur_speed = 0; if (--u->cur_speed == 32) SndPlayVehicleFx(SND_18_HELICOPTER, v); @@ -986,7 +958,7 @@ if (UpdateAircraftSpeed(v, SPEED_LIMIT_NONE)) { v->tile = 0; - // Reached altitude? + /* Reached altitude? */ if (v->z_pos >= 184) { v->cur_speed = 0; return true; @@ -997,28 +969,28 @@ return false; } - // Helicopter landing. + /* Helicopter landing. */ if (amd->flag & AMED_HELI_LOWER) { if (UpdateAircraftSpeed(v, SPEED_LIMIT_NONE)) { if (st->airport_tile == 0) { - // FIXME - AircraftController -> if station no longer exists, do not land - // helicopter will circle until sign disappears, then go to next order - // * what to do when it is the only order left, right now it just stays in 1 place + /* FIXME - AircraftController -> if station no longer exists, do not land + * helicopter will circle until sign disappears, then go to next order + * what to do when it is the only order left, right now it just stays in 1 place */ v->u.air.state = FLYING; AircraftNextAirportPos_and_Order(v); return false; } - // Vehicle is now at the airport. + /* Vehicle is now at the airport. */ v->tile = st->airport_tile; - // Find altitude of landing position. - z = GetSlopeZ(x, y) + 1 + afc->delta_z; + /* Find altitude of landing position. */ + uint z = GetSlopeZ(x, y) + 1 + afc->delta_z; if (z == v->z_pos) { - u = v->next->next; + Vehicle *u = v->next->next; - // Increase speed of rotors. When speed is 80, we've landed. + /* Increase speed of rotors. When speed is 80, we've landed. */ if (u->cur_speed >= 80) return true; u->cur_speed += 4; } else if (v->z_pos > z) { @@ -1030,21 +1002,19 @@ return false; } - // Get distance from destination pos to current pos. - dist = myabs(x + amd->x - v->x_pos) + myabs(y + amd->y - v->y_pos); + /* Get distance from destination pos to current pos. */ + uint dist = myabs(x + amd->x - v->x_pos) + myabs(y + amd->y - v->y_pos); - // Need exact position? + /* Need exact position? */ if (!(amd->flag & AMED_EXACTPOS) && dist <= (amd->flag & AMED_SLOWTURN ? 8U : 4U)) return true; - // At final pos? + /* At final pos? */ if (dist == 0) { - DirDiff dirdiff; - - // Change direction smoothly to final direction. - dirdiff = DirDifference(amd->direction, v->direction); - // if distance is 0, and plane points in right direction, no point in calling - // UpdateAircraftSpeed(). So do it only afterwards + /* Change direction smoothly to final direction. */ + DirDiff dirdiff = DirDifference(amd->direction, v->direction); + /* if distance is 0, and plane points in right direction, no point in calling + * UpdateAircraftSpeed(). So do it only afterwards */ if (dirdiff == DIRDIFF_SAME) { v->cur_speed = 0; return true; @@ -1063,8 +1033,8 @@ if (v->load_unload_time_rem != 0) v->load_unload_time_rem--; - // Turn. Do it slowly if in the air. - newdir = GetDirectionTowards(v, x + amd->x, y + amd->y); + /* Turn. Do it slowly if in the air. */ + Direction newdir = GetDirectionTowards(v, x + amd->x, y + amd->y); if (newdir != v->direction) { if (amd->flag & AMED_SLOWTURN) { if (v->load_unload_time_rem == 0) v->load_unload_time_rem = 8; @@ -1075,32 +1045,30 @@ } } - // Move vehicle. - GetNewVehiclePos(v, &gp); + /* Move vehicle. */ + GetNewVehiclePosResult gp = GetNewVehiclePos(v); v->tile = gp.new_tile; - // If vehicle is in the air, use tile coordinate 0. + /* If vehicle is in the air, use tile coordinate 0. */ if (amd->flag & (AMED_TAKEOFF | AMED_SLOWTURN | AMED_LAND)) v->tile = 0; - // Adjust Z for land or takeoff? - z = v->z_pos; + /* Adjust Z for land or takeoff? */ + uint z = v->z_pos; if (amd->flag & AMED_TAKEOFF) { - z += 2; - maxz = GetAircraftFlyingAltitude(v); - if (z > maxz) z = maxz; + z = min(z + 2, GetAircraftFlyingAltitude(v)); } if (amd->flag & AMED_LAND) { if (st->airport_tile == 0) { v->u.air.state = FLYING; AircraftNextAirportPos_and_Order(v); - // get aircraft back on running altitude + /* get aircraft back on running altitude */ SetAircraftPosition(v, gp.x, gp.y, GetAircraftFlyingAltitude(v)); return false; } - curz = GetSlopeZ(x, y) + 1; + uint curz = GetSlopeZ(x, y) + 1; if (curz > z) { z++; @@ -1112,9 +1080,9 @@ } } - // We've landed. Decrase speed when we're reaching end of runway. + /* We've landed. Decrase speed when we're reaching end of runway. */ if (amd->flag & AMED_BRAKE) { - curz = GetSlopeZ(x, y) + 1; + uint curz = GetSlopeZ(x, y) + 1; if (z > curz) { z--; @@ -1132,17 +1100,13 @@ static void HandleCrashedAircraft(Vehicle *v) { - uint32 r; - Station *st; - int z; - v->u.air.crashed_counter++; - st = GetStation(v->u.air.targetairport); + Station *st = GetStation(v->u.air.targetairport); - // make aircraft crash down to the ground + /* make aircraft crash down to the ground */ if (v->u.air.crashed_counter < 500 && st->airport_tile==0 && ((v->u.air.crashed_counter % 3) == 0) ) { - z = GetSlopeZ(v->x_pos, v->y_pos); + uint z = GetSlopeZ(v->x_pos, v->y_pos); v->z_pos -= 1; if (v->z_pos == z) { v->u.air.crashed_counter = 500; @@ -1151,6 +1115,7 @@ } if (v->u.air.crashed_counter < 650) { + uint32 r; if (CHANCE16R(1,32,r)) { static const DirDiff delta[] = { DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT @@ -1166,14 +1131,14 @@ EV_EXPLOSION_SMALL); } } else if (v->u.air.crashed_counter >= 10000) { - // remove rubble of crashed airplane + /* remove rubble of crashed airplane */ - // clear runway-in on all airports, set by crashing plane - // small airports use AIRPORT_BUSY, city airports use RUNWAY_IN_OUT_block, etc. - // but they all share the same number + /* clear runway-in on all airports, set by crashing plane + * small airports use AIRPORT_BUSY, city airports use RUNWAY_IN_OUT_block, etc. + * but they all share the same number */ CLRBITS(st->airport_flags, RUNWAY_IN_block); CLRBITS(st->airport_flags, RUNWAY_IN_OUT_block); // commuter airport - CLRBITS(st->airport_flags, RUNWAY_IN2_block); // intercontinental + CLRBITS(st->airport_flags, RUNWAY_IN2_block); // intercontinental BeginVehicleMove(v); EndVehicleMove(v); @@ -1232,8 +1197,6 @@ static void ProcessAircraftOrder(Vehicle *v) { - const Order *order; - switch (v->current_order.type) { case OT_GOTO_DEPOT: if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return; @@ -1250,7 +1213,7 @@ if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0; - order = GetVehicleOrder(v, v->cur_order_index); + const Order *order = GetVehicleOrder(v, v->cur_order_index); if (order == NULL) { v->current_order.type = OT_NOTHING; @@ -1267,7 +1230,7 @@ v->current_order = *order; - // orders are changed in flight, ensure going to the right station + /* orders are changed in flight, ensure going to the right station */ if (order->type == OT_GOTO_STATION && v->u.air.state == FLYING) { AircraftNextAirportPos_and_Order(v); } @@ -1325,10 +1288,6 @@ static void CrashAirplane(Vehicle *v) { - uint16 amt; - Station *st; - StringID newsitem; - v->vehstatus |= VS_CRASHED; v->u.air.crashed_counter = 0; @@ -1336,13 +1295,14 @@ InvalidateWindow(WC_VEHICLE_VIEW, v->index); - amt = 2; + uint amt = 2; if (v->cargo_type == CT_PASSENGERS) amt += v->cargo_count; SetDParam(0, amt); v->cargo_count = 0; v->next->cargo_count = 0; - st = GetStation(v->u.air.targetairport); + const Station *st = GetStation(v->u.air.targetairport); + StringID newsitem; if (st->airport_tile == 0) { newsitem = STR_PLANE_CRASH_OUT_OF_FUEL; } else { @@ -1361,14 +1321,10 @@ static void MaybeCrashAirplane(Vehicle *v) { - Station *st; - uint16 prob; - uint i; + Station *st = GetStation(v->u.air.targetairport); - st = GetStation(v->u.air.targetairport); - - //FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports - prob = 0x10000 / 1500; + /* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */ + uint16 prob = 0x10000 / 1500; if (st->Airport()->flags & AirportFTAClass::SHORT_STRIP && AircraftVehInfo(v->engine_type)->subtype & AIR_FAST && !_cheats.no_jetcrash.value) { @@ -1377,8 +1333,8 @@ if (GB(Random(), 0, 16) > prob) return; - // Crash the airplane. Remove all goods stored at the station. - for (i = 0; i != NUM_CARGO; i++) { + /* Crash the airplane. Remove all goods stored at the station. */ + for (uint i = 0; i != NUM_CARGO; i++) { st->goods[i].rating = 1; SB(st->goods[i].waiting_acceptance, 0, 12, 0); } @@ -1386,15 +1342,12 @@ CrashAirplane(v); } -// we've landed and just arrived at a terminal +/** we've landed and just arrived at a terminal */ static void AircraftEntersTerminal(Vehicle *v) { - Station *st; - Order old_order; - if (v->current_order.type == OT_GOTO_DEPOT) return; - st = GetStation(v->u.air.targetairport); + Station *st = GetStation(v->u.air.targetairport); v->last_station_visited = v->u.air.targetairport; /* Check if station was ever visited before */ @@ -1403,7 +1356,7 @@ st->had_vehicle_of_type |= HVOT_AIRCRAFT; SetDParam(0, st->index); - // show newsitem of celebrating citizens + /* show newsitem of celebrating citizens */ flags = (v->owner == _local_player) ? NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_PLAYER, 0) : NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_OTHER, 0); AddNewsItem( STR_A033_CITIZENS_CELEBRATE_FIRST, @@ -1412,7 +1365,7 @@ 0); } - old_order = v->current_order; + Order old_order = v->current_order; v->BeginLoading(); v->current_order.flags = 0; @@ -1480,7 +1433,7 @@ } -// set the right pos when heading to other airports after takeoff +/** set the right pos when heading to other airports after takeoff */ static void AircraftNextAirportPos_and_Order(Vehicle *v) { if (v->current_order.type == OT_GOTO_STATION || @@ -1502,7 +1455,7 @@ Vehicle *u = v->next; u->vehstatus &= ~VS_HIDDEN; - // Rotor blades + /* Rotor blades */ u = u->next; if (u != NULL) { u->vehstatus &= ~VS_HIDDEN; @@ -1532,16 +1485,16 @@ v->u.air.state = apc->layout[v->u.air.pos].heading; } -// In an Airport Hangar +/** In an Airport Hangar */ static void AircraftEventHandler_InHangar(Vehicle *v, const AirportFTAClass *apc) { - // if we just arrived, execute EnterHangar first + /* if we just arrived, execute EnterHangar first */ if (v->u.air.previous_pos != v->u.air.pos) { AircraftEventHandler_EnterHangar(v, apc); return; } - // if we were sent to the depot, stay there + /* if we were sent to the depot, stay there */ if (v->current_order.type == OT_GOTO_DEPOT && (v->vehstatus & VS_STOPPED)) { v->current_order.type = OT_NOTHING; v->current_order.flags = 0; @@ -1552,37 +1505,37 @@ v->current_order.type != OT_GOTO_DEPOT) return; - // if the block of the next position is busy, stay put + /* if the block of the next position is busy, stay put */ if (AirportHasBlock(v, &apc->layout[v->u.air.pos], apc)) return; - // We are already at the target airport, we need to find a terminal + /* We are already at the target airport, we need to find a terminal */ if (v->current_order.dest == v->u.air.targetairport) { - // FindFreeTerminal: - // 1. Find a free terminal, 2. Occupy it, 3. Set the vehicle's state to that terminal + /* FindFreeTerminal: + * 1. Find a free terminal, 2. Occupy it, 3. Set the vehicle's state to that terminal */ if (v->subtype == AIR_HELICOPTER) { if (!AirportFindFreeHelipad(v, apc)) return; // helicopter } else { if (!AirportFindFreeTerminal(v, apc)) return; // airplane } } else { // Else prepare for launch. - // airplane goto state takeoff, helicopter to helitakeoff + /* airplane goto state takeoff, helicopter to helitakeoff */ v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF; } AircraftLeaveHangar(v); AirportMove(v, apc); } -// At one of the Airport's Terminals +/** At one of the Airport's Terminals */ static void AircraftEventHandler_AtTerminal(Vehicle *v, const AirportFTAClass *apc) { - // if we just arrived, execute EnterTerminal first + /* if we just arrived, execute EnterTerminal first */ if (v->u.air.previous_pos != v->u.air.pos) { AircraftEventHandler_EnterTerminal(v, apc); - // on an airport with helipads, a helicopter will always land there - // and get serviced at the same time - patch setting + /* on an airport with helipads, a helicopter will always land there + * and get serviced at the same time - patch setting */ if (_patches.serviceathelipad) { if (v->subtype == AIR_HELICOPTER && apc->helipads != NULL) { - // an exerpt of ServiceAircraft, without the invisibility stuff + /* an exerpt of ServiceAircraft, without the invisibility stuff */ v->date_of_last_service = _date; v->breakdowns_since_last_service = 0; v->reliability = GetEngine(v->engine_type)->reliability; @@ -1594,15 +1547,15 @@ if (v->current_order.type == OT_NOTHING) return; - // if the block of the next position is busy, stay put + /* if the block of the next position is busy, stay put */ if (AirportHasBlock(v, &apc->layout[v->u.air.pos], apc)) return; - // airport-road is free. We either have to go to another airport, or to the hangar - // ---> start moving + /* airport-road is free. We either have to go to another airport, or to the hangar + * ---> start moving */ switch (v->current_order.type) { case OT_GOTO_STATION: // ready to fly to another airport - // airplane goto state takeoff, helicopter to helitakeoff + /* airplane goto state takeoff, helicopter to helitakeoff */ v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF; break; case OT_GOTO_DEPOT: // visit hangar for serivicing, sale, etc. @@ -1625,7 +1578,8 @@ assert("OK, you shouldn't be here, check your Airport Scheme!" && 0); } -static void AircraftEventHandler_TakeOff(Vehicle *v, const AirportFTAClass *apc) { +static void AircraftEventHandler_TakeOff(Vehicle *v, const AirportFTAClass *apc) +{ PlayAircraftSound(v); // play takeoffsound for airplanes v->u.air.state = STARTTAKEOFF; } @@ -1639,7 +1593,7 @@ static void AircraftEventHandler_EndTakeOff(Vehicle *v, const AirportFTAClass *apc) { v->u.air.state = FLYING; - // get the next position to go to, differs per airport + /* get the next position to go to, differs per airport */ AircraftNextAirportPos_and_Order(v); } @@ -1648,11 +1602,11 @@ const Player* p = GetPlayer(v->owner); v->sprite_width = v->sprite_height = 24; // ??? no idea what this is v->u.air.state = FLYING; - // get the next position to go to, differs per airport + /* get the next position to go to, differs per airport */ AircraftNextAirportPos_and_Order(v); - // check if the aircraft needs to be replaced or renewed and send it to a hangar if needed - // unless it is due for renewal but the engine is no longer available + /* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed + * unless it is due for renewal but the engine is no longer available */ if (v->owner == _local_player && ( EngineHasReplacementForPlayer(p, v->engine_type) || ((p->engine_renew && v->age - v->max_age > p->engine_renew_months * 30) && @@ -1666,33 +1620,29 @@ static void AircraftEventHandler_Flying(Vehicle *v, const AirportFTAClass *apc) { - Station *st; - byte landingtype; - AirportFTA *current; - uint16 tcur_speed, tsubspeed; + Station *st = GetStation(v->u.air.targetairport); - st = GetStation(v->u.air.targetairport); - // runway busy or not allowed to use this airstation, circle + /* runway busy or not allowed to use this airstation, circle */ if (apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES) && st->airport_tile != 0 && (st->owner == OWNER_NONE || st->owner == v->owner)) { // {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41}, // if it is an airplane, look for LANDING, for helicopter HELILANDING // it is possible to choose from multiple landing runways, so loop until a free one is found - landingtype = (v->subtype == AIR_HELICOPTER) ? HELILANDING : LANDING; - current = apc->layout[v->u.air.pos].next; + byte landingtype = (v->subtype == AIR_HELICOPTER) ? HELILANDING : LANDING; + const AirportFTA *current = apc->layout[v->u.air.pos].next; while (current != NULL) { if (current->heading == landingtype) { - // save speed before, since if AirportHasBlock is false, it resets them to 0 - // we don't want that for plane in air - // hack for speed thingie - tcur_speed = v->cur_speed; - tsubspeed = v->subspeed; + /* save speed before, since if AirportHasBlock is false, it resets them to 0 + * we don't want that for plane in air + * hack for speed thingie */ + uint16 tcur_speed = v->cur_speed; + uint16 tsubspeed = v->subspeed; if (!AirportHasBlock(v, current, apc)) { v->u.air.state = landingtype; // LANDING / HELILANDING - // it's a bit dirty, but I need to set position to next position, otherwise - // if there are multiple runways, plane won't know which one it took (because - // they all have heading LANDING). And also occupy that block! + /* it's a bit dirty, but I need to set position to next position, otherwise + * if there are multiple runways, plane won't know which one it took (because + * they all have heading LANDING). And also occupy that block! */ v->u.air.pos = current->next_position; SETBITS(st->airport_flags, apc->layout[v->u.air.pos].block); return; @@ -1709,15 +1659,15 @@ static void AircraftEventHandler_Landing(Vehicle *v, const AirportFTAClass *apc) { - const Player* p = GetPlayer(v->owner); AircraftLandAirplane(v); // maybe crash airplane v->u.air.state = ENDLANDING; - // check if the aircraft needs to be replaced or renewed and send it to a hangar if needed + /* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */ if (v->current_order.type != OT_GOTO_DEPOT && v->owner == _local_player) { - // only the vehicle owner needs to calculate the rest (locally) + /* only the vehicle owner needs to calculate the rest (locally) */ + const Player* p = GetPlayer(v->owner); if (EngineHasReplacementForPlayer(p, v->engine_type) || (p->engine_renew && v->age - v->max_age > (p->engine_renew_months * 30))) { - // send the aircraft to the hangar at next airport + /* send the aircraft to the hangar at next airport */ _current_player = _local_player; DoCommandP(v->tile, v->index, DEPOT_SERVICE, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR); _current_player = OWNER_NONE; @@ -1733,13 +1683,13 @@ static void AircraftEventHandler_EndLanding(Vehicle *v, const AirportFTAClass *apc) { - // next block busy, don't do a thing, just wait + /* next block busy, don't do a thing, just wait */ if (AirportHasBlock(v, &apc->layout[v->u.air.pos], apc)) return; - // if going to terminal (OT_GOTO_STATION) choose one - // 1. in case all terminals are busy AirportFindFreeTerminal() returns false or - // 2. not going for terminal (but depot, no order), - // --> get out of the way to the hangar. + /* if going to terminal (OT_GOTO_STATION) choose one + * 1. in case all terminals are busy AirportFindFreeTerminal() returns false or + * 2. not going for terminal (but depot, no order), + * --> get out of the way to the hangar. */ if (v->current_order.type == OT_GOTO_STATION) { if (AirportFindFreeTerminal(v, apc)) return; } @@ -1749,16 +1699,16 @@ static void AircraftEventHandler_HeliEndLanding(Vehicle *v, const AirportFTAClass *apc) { - // next block busy, don't do a thing, just wait + /* next block busy, don't do a thing, just wait */ if (AirportHasBlock(v, &apc->layout[v->u.air.pos], apc)) return; - // if going to helipad (OT_GOTO_STATION) choose one. If airport doesn't have helipads, choose terminal - // 1. in case all terminals/helipads are busy (AirportFindFreeHelipad() returns false) or - // 2. not going for terminal (but depot, no order), - // --> get out of the way to the hangar IF there are terminals on the airport. - // --> else TAKEOFF - // the reason behind this is that if an airport has a terminal, it also has a hangar. Airplanes - // must go to a hangar. + /* if going to helipad (OT_GOTO_STATION) choose one. If airport doesn't have helipads, choose terminal + * 1. in case all terminals/helipads are busy (AirportFindFreeHelipad() returns false) or + * 2. not going for terminal (but depot, no order), + * --> get out of the way to the hangar IF there are terminals on the airport. + * --> else TAKEOFF + * the reason behind this is that if an airport has a terminal, it also has a hangar. Airplanes + * must go to a hangar. */ if (v->current_order.type == OT_GOTO_STATION) { if (AirportFindFreeHelipad(v, apc)) return; } @@ -1794,7 +1744,7 @@ static void AirportClearBlock(const Vehicle *v, const AirportFTAClass *apc) { - // we have left the previous block, and entered the new one. Free the previous block + /* we have left the previous block, and entered the new one. Free the previous block */ if (apc->layout[v->u.air.previous_pos].block != apc->layout[v->u.air.pos].block) { Station *st = GetStation(v->u.air.targetairport); @@ -1802,31 +1752,30 @@ } } -static void AirportGoToNextPosition(Vehicle *v, const AirportFTAClass *apc) +static void AirportGoToNextPosition(Vehicle *v) { - // if aircraft is not in position, wait until it is + /* if aircraft is not in position, wait until it is */ if (!AircraftController(v)) return; + const AirportFTAClass *apc = GetStation(v->u.air.targetairport)->Airport(); + AirportClearBlock(v, apc); AirportMove(v, apc); // move aircraft to next position } -// gets pos from vehicle and next orders +/* gets pos from vehicle and next orders */ static bool AirportMove(Vehicle *v, const AirportFTAClass *apc) { - AirportFTA *current; - byte prev_pos; - - // error handling + /* error handling */ if (v->u.air.pos >= apc->nofelements) { DEBUG(misc, 0, "[Ap] position %d is not valid for current airport. Max position is %d", v->u.air.pos, apc->nofelements-1); assert(v->u.air.pos < apc->nofelements); } - current = &apc->layout[v->u.air.pos]; - // we have arrived in an important state (eg terminal, hangar, etc.) + const AirportFTA *current = &apc->layout[v->u.air.pos]; + /* we have arrived in an important state (eg terminal, hangar, etc.) */ if (current->heading == v->u.air.state) { - prev_pos = v->u.air.pos; // location could be changed in state, so save it before-hand + byte prev_pos = v->u.air.pos; // location could be changed in state, so save it before-hand _aircraft_state_handlers[v->u.air.state](v, apc); if (v->u.air.state != FLYING) v->u.air.previous_pos = prev_pos; return true; @@ -1834,7 +1783,7 @@ v->u.air.previous_pos = v->u.air.pos; // save previous location - // there is only one choice to move to + /* there is only one choice to move to */ if (current->next == NULL) { if (AirportSetBlocks(v, current, apc)) { v->u.air.pos = current->next_position; @@ -1842,8 +1791,8 @@ return false; } - // there are more choices to choose from, choose the one that - // matches our heading + /* there are more choices to choose from, choose the one that + * matches our heading */ do { if (v->u.air.state == current->heading || current->heading == TO_ALL) { if (AirportSetBlocks(v, current, apc)) { @@ -1859,18 +1808,18 @@ return false; } -// returns true if the road ahead is busy, eg. you must wait before proceeding +/* returns true if the road ahead is busy, eg. you must wait before proceeding */ static bool AirportHasBlock(Vehicle *v, const AirportFTA *current_pos, const AirportFTAClass *apc) { const AirportFTA *reference = &apc->layout[v->u.air.pos]; const AirportFTA *next = &apc->layout[current_pos->next_position]; - // same block, then of course we can move + /* same block, then of course we can move */ if (apc->layout[current_pos->position].block != next->block) { const Station *st = GetStation(v->u.air.targetairport); uint64 airport_flags = next->block; - // check additional possible extra blocks + /* check additional possible extra blocks */ if (current_pos != reference && current_pos->block != NOTHING_block) { airport_flags |= current_pos->block; } @@ -1884,19 +1833,24 @@ return false; } -// returns true on success. Eg, next block was free and we have occupied it -static bool AirportSetBlocks(Vehicle *v, AirportFTA *current_pos, const AirportFTAClass *apc) +/** + * ... + * @param v airplane that requires the operation + * @param currentpos of the vehicle in the list of blocks + * @param apc airport on which block is requsted to be set + * @returns true on success. Eg, next block was free and we have occupied it + */ +static bool AirportSetBlocks(Vehicle *v, const AirportFTA *current_pos, const AirportFTAClass *apc) { - AirportFTA *next = &apc->layout[current_pos->next_position]; - AirportFTA *reference = &apc->layout[v->u.air.pos]; + const AirportFTA *next = &apc->layout[current_pos->next_position]; + const AirportFTA *reference = &apc->layout[v->u.air.pos]; - // if the next position is in another block, check it and wait until it is free + /* if the next position is in another block, check it and wait until it is free */ if ((apc->layout[current_pos->position].block & next->block) != next->block) { uint64 airport_flags = next->block; - Station* st = GetStation(v->u.air.targetairport); - //search for all all elements in the list with the same state, and blocks != N - // this means more blocks should be checked/set - AirportFTA *current = current_pos; + /* search for all all elements in the list with the same state, and blocks != N + * this means more blocks should be checked/set */ + const AirportFTA *current = current_pos; if (current == reference) current = current->next; while (current != NULL) { if (current->heading == current_pos->heading && current->block != 0) { @@ -1906,10 +1860,11 @@ current = current->next; }; - // if the block to be checked is in the next position, then exclude that from - // checking, because it has been set by the airplane before + /* if the block to be checked is in the next position, then exclude that from + * checking, because it has been set by the airplane before */ if (current_pos->block == next->block) airport_flags ^= next->block; + Station* st = GetStation(v->u.air.targetairport); if (HASBITS(st->airport_flags, airport_flags)) { v->cur_speed = 0; v->subspeed = 0; @@ -1928,7 +1883,7 @@ Station *st = GetStation(v->u.air.targetairport); for (; i < last_terminal; i++) { if (!HASBIT(st->airport_flags, _airport_terminal_flag[i])) { - // TERMINAL# HELIPAD# + /* TERMINAL# HELIPAD# */ v->u.air.state = _airport_terminal_state[i]; // start moving to that terminal/helipad SETBIT(st->airport_flags, _airport_terminal_flag[i]); // occupy terminal/helipad return true; @@ -1940,9 +1895,8 @@ static uint GetNumTerminals(const AirportFTAClass *apc) { uint num = 0; - uint i; - for (i = apc->terminals[0]; i > 0; i--) num += apc->terminals[i]; + for (uint i = apc->terminals[0]; i > 0; i--) num += apc->terminals[i]; return num; } @@ -1960,28 +1914,25 @@ * fails, then attempt fails and plane waits */ if (apc->terminals[0] > 1) { - Station *st = GetStation(v->u.air.targetairport); - AirportFTA *temp = apc->layout[v->u.air.pos].next; + const Station *st = GetStation(v->u.air.targetairport); + const AirportFTA *temp = apc->layout[v->u.air.pos].next; while (temp != NULL) { if (temp->heading == 255) { if (!HASBITS(st->airport_flags, temp->block)) { - int target_group; - int i; - int group_start = 0; - int group_end; + /* read which group do we want to go to? + * (the first free group) */ + uint target_group = temp->next_position + 1; - //read which group do we want to go to? - //(the first free group) - target_group = temp->next_position + 1; + /* at what terminal does the group start? + * that means, sum up all terminals of + * groups with lower number */ + uint group_start = 0; + for (uint i = 1; i < target_group; i++) { + group_start += apc->terminals[i]; + } - //at what terminal does the group start? - //that means, sum up all terminals of - //groups with lower number - for (i = 1; i < target_group; i++) - group_start += apc->terminals[i]; - - group_end = group_start + apc->terminals[target_group]; + uint group_end = group_start + apc->terminals[target_group]; if (FreeTerminal(v, group_start, group_end)) return true; } } else { @@ -1993,16 +1944,15 @@ } } - // if there is only 1 terminalgroup, all terminals are checked (starting from 0 to max) + /* if there is only 1 terminalgroup, all terminals are checked (starting from 0 to max) */ return FreeTerminal(v, 0, GetNumTerminals(apc)); } static uint GetNumHelipads(const AirportFTAClass *apc) { uint num = 0; - uint i; - for (i = apc->helipads[0]; i > 0; i--) num += apc->helipads[i]; + for (uint i = apc->helipads[0]; i > 0; i--) num += apc->helipads[i]; return num; } @@ -2010,10 +1960,10 @@ static bool AirportFindFreeHelipad(Vehicle *v, const AirportFTAClass *apc) { - // if an airport doesn't have helipads, use terminals + /* if an airport doesn't have helipads, use terminals */ if (apc->helipads == NULL) return AirportFindFreeTerminal(v, apc); - // if there are more helicoptergroups, pick one, just as in AirportFindFreeTerminal() + /* if there are more helicoptergroups, pick one, just as in AirportFindFreeTerminal() */ if (apc->helipads[0] > 1) { const Station* st = GetStation(v->u.air.targetairport); const AirportFTA* temp = apc->layout[v->u.air.pos].next; @@ -2021,22 +1971,20 @@ while (temp != NULL) { if (temp->heading == 255) { if (!HASBITS(st->airport_flags, temp->block)) { - int target_group; - int i; - int group_start = 0; - int group_end; - //read which group do we want to go to? - //(the first free group) - target_group = temp->next_position + 1; + /* read which group do we want to go to? + * (the first free group) */ + uint target_group = temp->next_position + 1; - //at what terminal does the group start? - //that means, sum up all terminals of - //groups with lower number - for (i = 1; i < target_group; i++) + /* at what terminal does the group start? + * that means, sum up all terminals of + * groups with lower number */ + uint group_start = 0; + for (uint i = 1; i < target_group; i++) { group_start += apc->helipads[i]; + } - group_end = group_start + apc->helipads[target_group]; + uint group_end = group_start + apc->helipads[target_group]; if (FreeTerminal(v, group_start, group_end)) return true; } } else { @@ -2047,8 +1995,8 @@ temp = temp->next; } } else { - // only 1 helicoptergroup, check all helipads - // The blocks for helipads start after the last terminal (MAX_TERMINALS) + /* only 1 helicoptergroup, check all helipads + * The blocks for helipads start after the last terminal (MAX_TERMINALS) */ return FreeTerminal(v, MAX_TERMINALS, GetNumHelipads(apc) + MAX_TERMINALS); } return false; // it shouldn't get here anytime, but just to be sure @@ -2080,20 +2028,18 @@ if (v->current_order.type >= OT_LOADING) return; - AirportGoToNextPosition(v, GetStation(v->u.air.targetairport)->Airport()); + AirportGoToNextPosition(v); } void Aircraft_Tick(Vehicle *v) { - int i; - if (!IsNormalAircraft(v)) return; if (v->subtype == AIR_HELICOPTER) HelicopterTickHandler(v); AgeAircraftCargo(v); - for (i = 0; i != 6; i++) { + for (uint i = 0; i != 6; i++) { AircraftEventHandler(v, i); if (v->type != VEH_Aircraft) // In case it was deleted break; @@ -2101,23 +2047,21 @@ } -// need to be called to load aircraft from old version +/** need to be called to load aircraft from old version */ void UpdateOldAircraft(void) { + /* set airport_flags to 0 for all airports just to be sure */ Station *st; - Vehicle *v_oldstyle; - GetNewVehiclePosResult gp; - - // set airport_flags to 0 for all airports just to be sure FOR_ALL_STATIONS(st) { st->airport_flags = 0; // reset airport } + Vehicle *v_oldstyle; FOR_ALL_VEHICLES(v_oldstyle) { - // airplane has another vehicle with subtype 4 (shadow), helicopter also has 3 (rotor) - // skip those + /* airplane has another vehicle with subtype 4 (shadow), helicopter also has 3 (rotor) + * skip those */ if (v_oldstyle->type == VEH_Aircraft && IsNormalAircraft(v_oldstyle)) { - // airplane in terminal stopped doesn't hurt anyone, so goto next + /* airplane in terminal stopped doesn't hurt anyone, so goto next */ if (v_oldstyle->vehstatus & VS_STOPPED && v_oldstyle->u.air.state == 0) { v_oldstyle->u.air.state = HANGAR; continue; @@ -2127,46 +2071,43 @@ v_oldstyle->vehstatus &= ~VS_STOPPED; // make airplane moving v_oldstyle->u.air.state = FLYING; AircraftNextAirportPos_and_Order(v_oldstyle); // move it to the entry point of the airport - GetNewVehiclePos(v_oldstyle, &gp); // get the position of the plane (to be used for setting) + GetNewVehiclePosResult gp = GetNewVehiclePos(v_oldstyle); v_oldstyle->tile = 0; // aircraft in air is tile=0 - // correct speed of helicopter-rotors + /* correct speed of helicopter-rotors */ if (v_oldstyle->subtype == AIR_HELICOPTER) v_oldstyle->next->next->cur_speed = 32; - // set new position x,y,z + /* set new position x,y,z */ SetAircraftPosition(v_oldstyle, gp.x, gp.y, GetAircraftFlyingAltitude(v_oldstyle)); } } } -void UpdateAirplanesOnNewStation(Station *st) +void UpdateAirplanesOnNewStation(const Station *st) { - GetNewVehiclePosResult gp; + /* only 1 station is updated per function call, so it is enough to get entry_point once */ + const AirportFTAClass *ap = st->Airport(); + Vehicle *v; - byte takeofftype; - uint16 cnt; - // only 1 station is updated per function call, so it is enough to get entry_point once - const AirportFTAClass *ap = st->Airport(); FOR_ALL_VEHICLES(v) { if (v->type == VEH_Aircraft && IsNormalAircraft(v)) { if (v->u.air.targetairport == st->index) { // if heading to this airport /* update position of airplane. If plane is not flying, landing, or taking off - *you cannot delete airport, so it doesn't matter - */ + *you cannot delete airport, so it doesn't matter */ if (v->u.air.state >= FLYING) { // circle around v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, ap); v->u.air.state = FLYING; - // landing plane needs to be reset to flying height (only if in pause mode upgrade, - // in normal mode, plane is reset in AircraftController. It doesn't hurt for FLYING - GetNewVehiclePos(v, &gp); - // set new position x,y,z + /* landing plane needs to be reset to flying height (only if in pause mode upgrade, + * in normal mode, plane is reset in AircraftController. It doesn't hurt for FLYING */ + GetNewVehiclePosResult gp = GetNewVehiclePos(v); + /* set new position x,y,z */ SetAircraftPosition(v, gp.x, gp.y, GetAircraftFlyingAltitude(v)); } else { assert(v->u.air.state == ENDTAKEOFF || v->u.air.state == HELITAKEOFF); - takeofftype = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : ENDTAKEOFF; - // search in airportdata for that heading - // easiest to do, since this doesn't happen a lot - for (cnt = 0; cnt < ap->nofelements; cnt++) { + byte takeofftype = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : ENDTAKEOFF; + /* search in airportdata for that heading + * easiest to do, since this doesn't happen a lot */ + for (uint cnt = 0; cnt < ap->nofelements; cnt++) { if (ap->layout[cnt].heading == takeofftype) { v->u.air.pos = ap->layout[cnt].position; break; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/aircraft_gui.cpp --- a/src/aircraft_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/aircraft_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file aircraft_gui.cpp */ + #include "stdafx.h" #include "openttd.h" #include "aircraft.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/airport.cpp --- a/src/airport.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/airport.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file airport.cpp */ + #include "stdafx.h" #include "openttd.h" #include "debug.h" @@ -288,11 +290,10 @@ * know one element from the other by differing 'position' identifiers */ static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA) { - int i; uint16 nofelements = 0; int temp = apFA[0].position; - for (i = 0; i < MAX_ELEMENTS; i++) { + for (uint i = 0; i < MAX_ELEMENTS; i++) { if (temp != apFA[i].position) { nofelements++; temp = apFA[i].position; @@ -307,12 +308,11 @@ * groups there are, and then the number of terminals for each group */ static byte AirportGetTerminalCount(const byte *terminals, byte *groups) { - byte i; byte nof_terminals = 0; *groups = 0; if (terminals != NULL) { - i = terminals[0]; + uint i = terminals[0]; *groups = i; while (i-- > 0) { terminals++; @@ -326,12 +326,11 @@ static AirportFTA* AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA) { - AirportFTA *current; AirportFTA *FAutomata = MallocT(nofelements); uint16 internalcounter = 0; for (uint i = 0; i < nofelements; i++) { - current = &FAutomata[i]; + AirportFTA *current = &FAutomata[i]; current->position = apFA[internalcounter].position; current->heading = apFA[internalcounter].heading; current->block = apFA[internalcounter].block; @@ -349,7 +348,7 @@ current->next = newNode; current = current->next; internalcounter++; - } // while + } current->next = NULL; internalcounter++; } @@ -365,9 +364,8 @@ uint position = layout[i].position; if (position != next_position) return i; const AirportFTA *first = &layout[i]; - const AirportFTA *current = first; - for (; current != NULL; current = current->next) { + for (const AirportFTA *current = first; current != NULL; current = current->next) { /* A heading must always be valid. The only exceptions are * - multiple choices as start, identified by a special value of 255 * - terminal group which is identified by a special value of 255 */ @@ -434,9 +432,7 @@ if (!full_report) printf("(P = Current Position; NP = Next Position)\n"); for (uint i = 0; i < nofelements; i++) { - const AirportFTA *current = &layout[i]; - - for (; current != NULL; current = current->next) { + for (const AirportFTA *current = &layout[i]; current != NULL; current = current->next) { if (full_report) { byte heading = (current->heading == 255) ? MAX_HEADINGS + 1 : current->heading; printf("\tPos:%2d NPos:%2d Heading:%15s Block:%2d\n", current->position, diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/airport.h --- a/src/airport.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/airport.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file airport.h Various declarations for airports */ + #ifndef AIRPORT_H #define AIRPORT_H diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/airport_gui.cpp --- a/src/airport_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/airport_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file airport_gui.cpp */ + #include "stdafx.h" #include "openttd.h" #include "table/sprites.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/airport_movement.h --- a/src/airport_movement.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/airport_movement.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file airport_movement.h Heart of the airports and their finite state machines */ + #ifndef AIRPORT_MOVEMENT_H #define AIRPORT_MOVEMENT_H @@ -406,7 +408,7 @@ static const TileIndexDiffC _airport_depots_commuter[] = { { 4, 0 } }; static const byte _airport_terminal_commuter[] = { 1, 3 }; static const byte _airport_helipad_commuter[] = { 1, 2 }; -static const byte _airport_entries_commuter[] = {7, 7, 7, 7}; +static const byte _airport_entries_commuter[] = {21, 21, 21, 21}; static const AirportFTAbuildup _airport_fta_commuter[] = { { 0, HANGAR, NOTHING_block, 1 }, { 0, HELITAKEOFF, HELIPAD2_block, 1 }, { 0, 0, 0, 1 }, { 1, 255, TAXIWAY_BUSY_block, 0 }, { 1, HANGAR, 0, 0 }, { 1, TAKEOFF, 0, 11 }, { 1, TERM1, TAXIWAY_BUSY_block, 10 }, { 1, TERM2, TAXIWAY_BUSY_block, 10 }, { 1, TERM3, TAXIWAY_BUSY_block, 10 }, { 1, HELIPAD1, TAXIWAY_BUSY_block, 10 }, { 1, HELIPAD2, TAXIWAY_BUSY_block, 10 }, { 1, HELITAKEOFF, TAXIWAY_BUSY_block, 10 }, { 1, 0, 0, 0 }, diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/autoreplace_gui.cpp --- a/src/autoreplace_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/autoreplace_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file autoreplace_gui.cpp */ + #include "stdafx.h" #include "openttd.h" #include "debug.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/aystar.cpp --- a/src/aystar.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/aystar.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file aystar.cpp */ + /* * This file has the core function for AyStar * AyStar is a fast pathfinding routine and is used for things like diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/aystar.h --- a/src/aystar.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/aystar.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,6 +1,6 @@ /* $Id$ */ -/* +/** @file aystar.h * This file has the header for AyStar * AyStar is a fast pathfinding routine and is used for things like * AI_pathfinding and Train_pathfinding. diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/bmp.cpp --- a/src/bmp.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/bmp.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file bmp.cpp */ + #include "stdafx.h" #include "openttd.h" #include "gfx.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/bmp.h --- a/src/bmp.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/bmp.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file bmp.h */ + #ifndef BMP_H #define BMP_H diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/bridge.h --- a/src/bridge.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/bridge.h Wed Feb 28 00:33:40 2007 +0000 @@ -28,6 +28,11 @@ extern Bridge _bridge[MAX_BRIDGES]; uint GetBridgeFoundation(Slope tileh, Axis axis); -uint SetSpeedLimitOnBridge(Vehicle *); + +static inline const Bridge *GetBridge(uint i) +{ + assert(i < lengthof(_bridge)); + return &_bridge[i]; +} #endif /* BRIDGE_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/bridge_gui.cpp --- a/src/bridge_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/bridge_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,6 +1,6 @@ /* $Id$ */ -/** @file bridge_gui.c Graphical user interface for bridge construction*/ +/** @file bridge_gui.cpp Graphical user interface for bridge construction */ #include "stdafx.h" #include "openttd.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/bridge_map.cpp --- a/src/bridge_map.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/bridge_map.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file bridge_map.cpp */ + #include "stdafx.h" #include "openttd.h" #include "bridge_map.h" @@ -43,7 +45,7 @@ Slope tileh = GetTileSlope(t, &h); uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t))); - // one height level extra if the ramp is on a flat foundation + /* one height level extra if the ramp is on a flat foundation */ return h + TILE_HEIGHT + (IS_INT_INSIDE(f, 1, 15) ? TILE_HEIGHT : 0) + diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/bridge_map.h --- a/src/bridge_map.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/bridge_map.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file bridge_map.h */ + #ifndef BRIDGE_MAP_H #define BRIDGE_MAP_H @@ -59,6 +61,8 @@ /** * Get the direction pointing onto the bridge + * @param tile The tile to analyze + * @return the above mentionned direction */ static inline DiagDirection GetBridgeRampDirection(TileIndex t) { diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/build_vehicle_gui.cpp --- a/src/build_vehicle_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/build_vehicle_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file build_vehicle_gui.cpp */ + #include "stdafx.h" #include "openttd.h" #include "train.h" @@ -24,6 +26,7 @@ #include "newgrf_engine.h" #include "date.h" #include "strings.h" +#include "cargotype.h" enum BuildVehicleWidgets { @@ -381,7 +384,7 @@ /* Wagon weight - (including cargo) */ SetDParam(0, rvi->weight); - SetDParam(1, (_cargoc.weights[rvi->cargo_type] * rvi->capacity >> 4) + rvi->weight); + SetDParam(1, (GetCargo(rvi->cargo_type)->weight * rvi->capacity >> 4) + rvi->weight); DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, 0); y += 10; @@ -505,7 +508,7 @@ /* Note, if the default capacity is selected by the refit capacity * callback, then the capacity shown is likely to be incorrect. */ SetDParam(0, cargo); - SetDParam(1, AircraftDefaultCargoCapacity(cargo, engine_number)); + SetDParam(1, AircraftDefaultCargoCapacity(cargo, avi)); SetDParam(2, STR_9842_REFITTABLE); DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); } @@ -606,9 +609,9 @@ EngList_RemoveAll(&bv->eng_list); /* Make list of all available train engines and wagons. - * 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 */ + * 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++) { const RailVehicleInfo *rvi = RailVehInfo(eid); @@ -627,15 +630,15 @@ bv->sel_engine = sel_id; - // make engines first, and then wagons, sorted by ListPositionOfEngine() + /* make engines first, and then wagons, sorted by ListPositionOfEngine() */ _internal_sort_order = false; EngList_Sort(&bv->eng_list, TrainEnginesThenWagonsSorter); - // and then sort engines + /* and then sort engines */ _internal_sort_order = bv->descending_sort_order; EngList_SortPartial(&bv->eng_list, _sorter[0][bv->sort_criteria], 0, num_engines); - // and finally sort wagons + /* and finally sort wagons */ EngList_SortPartial(&bv->eng_list, _sorter[0][bv->sort_criteria], num_engines, num_wagons); } @@ -693,13 +696,13 @@ for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) { if (IsEngineBuildable(eid, VEH_Aircraft, _local_player)) { const AircraftVehicleInfo *avi = AircraftVehInfo(eid); - switch (bv->filter.flags & ~AirportFTAClass::SHORT_STRIP /* we don't care about the length of the runway here */) { + switch (bv->filter.flags & ~AirportFTAClass::SHORT_STRIP) { // we don't care about the length of the runway here case AirportFTAClass::HELICOPTERS: - if (avi->subtype != AIR_HELICOPTER) continue; + if (avi->subtype != AIR_HELI) continue; break; case AirportFTAClass::AIRPLANES: - if (avi->subtype != AIR_AIRCRAFT) continue; + if (!(avi->subtype & AIR_CTOL)) continue; break; case AirportFTAClass::ALL: break; @@ -707,9 +710,6 @@ NOT_REACHED(); } - if (bv->filter.flags & AirportFTAClass::SHORT_STRIP && - avi->subtype & AIR_FAST && !_cheats.no_jetcrash.value) continue; // don't build large aircraft in small airports - EngList_Add(&bv->eng_list, eid); if (eid == bv->sel_engine) sel_id = eid; @@ -936,7 +936,7 @@ break; } - case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ + case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list if (bv->sort_criteria != e->we.dropdown.index) { bv->sort_criteria = e->we.dropdown.index; _last_sort_criteria[bv->vehicle_type] = bv->sort_criteria; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/callback_table.cpp --- a/src/callback_table.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/callback_table.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,57 +1,59 @@ /* $Id$ */ +/** @file callback_table.cpp */ + #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! -// If you don't do it, it won't work across the network!! +/* If you add a callback for DoCommandP, also add the callback in here + * see below for the full list! + * If you don't do it, it won't work across the network!! */ -/* aircraft_gui.c */ +/* aircraft_gui.cpp */ CommandCallback CcBuildAircraft; CommandCallback CcCloneAircraft; -/* airport_gui.c */ +/* airport_gui.cpp */ CommandCallback CcBuildAirport; -/* bridge_gui.c */ +/* bridge_gui.cpp */ CommandCallback CcBuildBridge; -/* dock_gui.c */ +/* dock_gui.cpp */ CommandCallback CcBuildDocks; CommandCallback CcBuildCanal; -/* depot_gui.c */ +/* depot_gui.cpp */ CommandCallback CcCloneVehicle; -/* main_gui.c */ +/* main_gui.cpp */ CommandCallback CcPlaySound10; CommandCallback CcPlaceSign; CommandCallback CcTerraform; CommandCallback CcBuildTown; -/* rail_gui.c */ +/* rail_gui.cpp */ CommandCallback CcPlaySound1E; CommandCallback CcRailDepot; CommandCallback CcStation; CommandCallback CcBuildRailTunnel; -/* road_gui.c */ +/* road_gui.cpp */ CommandCallback CcPlaySound1D; CommandCallback CcBuildRoadTunnel; CommandCallback CcRoadDepot; -/* roadveh_gui.c */ +/* roadveh_gui.cpp */ CommandCallback CcBuildRoadVeh; CommandCallback CcCloneRoadVeh; -/* ship_gui.c */ +/* ship_gui.cpp */ CommandCallback CcBuildShip; CommandCallback CcCloneShip; -/* train_gui.c */ +/* train_gui.cpp */ CommandCallback CcBuildWagon; CommandCallback CcBuildLoco; CommandCallback CcCloneTrain; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/callback_table.h --- a/src/callback_table.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/callback_table.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file callback_table.h */ + #ifndef CALLBACK_TABLE_H #define CALLBACK_TABLE_H diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/cargotype.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cargotype.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -0,0 +1,72 @@ +/* $Id$ */ + +/** @file cargotype.cpp */ + +#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 "table/cargo_const.h" + +static CargoSpec _cargo[NUM_CARGO]; + +static const byte INVALID_CARGO = 0xFF; + +/* Bitmask of cargo types available */ +uint32 _cargo_mask; + + +void SetupCargoForClimate(LandscapeID l) +{ + assert(l < lengthof(_default_climate_cargo)); + + /* Reset and disable all cargo types */ + memset(_cargo, 0, sizeof(_cargo)); + for (CargoID i = 0; i < lengthof(_cargo); i++) _cargo[i].bitnum = INVALID_CARGO; + + _cargo_mask = 0; + + for (CargoID i = 0; i < lengthof(_default_climate_cargo[l]); i++) { + CargoLabel cl = _default_climate_cargo[l][i]; + + /* Loop through each of the default cargo types to see if + * the label matches */ + for (uint j = 0; j < lengthof(_default_cargo); j++) { + if (_default_cargo[j].label == cl) { + _cargo[i] = _default_cargo[j]; + + /* Populate the available cargo mask */ + SETBIT(_cargo_mask, i); + break; + } + } + } +} + + +const CargoSpec *GetCargo(CargoID c) +{ + assert(c < lengthof(_cargo)); + return &_cargo[c]; +} + + +bool CargoSpec::IsValid() const +{ + return bitnum != INVALID_CARGO; +} + + +CargoID GetCargoIDByLabel(CargoLabel cl) +{ + for (CargoID c = 0; c < lengthof(_cargo); c++) { + if (_cargo[c].label == cl) return c; + } + + /* No matching label was found, so it is invalid */ + return CT_INVALID; +} diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/cargotype.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cargotype.h Wed Feb 28 00:33:40 2007 +0000 @@ -0,0 +1,52 @@ +/* $Id$ */ + +/** @file cargotype.h */ + +#ifndef CARGOTYPE_H +#define CARGOTYPE_H + + +typedef uint32 CargoLabel; + + +typedef struct CargoSpec { + uint8 bitnum; + CargoLabel label; + uint32 grfid; + uint8 legend_colour; + uint8 rating_colour; + uint8 weight; + uint16 initial_payment; + uint8 transit_days[2]; + + bool is_freight; + uint8 substitutetowngrowth; + uint16 multipliertowngrowth; + uint8 callbackflags; + + StringID name; + StringID name_plural; + StringID units_volume; + StringID quantifier; + StringID abbrev; + + SpriteID sprite; + + uint16 classes; + + bool IsValid() const; +} CargoSpec; + + +extern uint32 _cargo_mask; + + +/* Set up the default cargo types for the given landscape type */ +void SetupCargoForClimate(LandscapeID l); +/* Retrieve cargo details for the given cargo ID */ +const CargoSpec *GetCargo(CargoID c); +/* Get the cargo ID with the cargo label */ +CargoID GetCargoIDByLabel(CargoLabel cl); + + +#endif /* CARGOTYPE_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/clear_cmd.cpp --- a/src/clear_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/clear_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file clear_cmd.cpp */ + #include "stdafx.h" #include "openttd.h" #include "clear_map.h" @@ -107,9 +109,9 @@ Slope tileh; uint z; - // Nothing could be built at the steep slope - this avoids a bug - // when you have a single diagonal track in one corner on a - // basement and then you raise/lower the other corner. + /* Nothing could be built at the steep slope - this avoids a bug + * when you have a single diagonal track in one corner on a + * basement and then you raise/lower the other corner. */ tileh = GetTileSlope(tile, &z); if (tileh == unsafe_slope[mode] || tileh == ComplementSlope(unsafe_slope[mode])) { @@ -118,8 +120,8 @@ return -1; } - // If we have a single diagonal track there, the other side of - // tile can be terraformed. + /* If we have a single diagonal track there, the other side of + * tile can be terraformed. */ if (IsPlainRailTile(tile) && GetTrackBits(tile) == safe_track[mode]) { /* If terraforming downwards prevent damaging a potential tunnel below. * This check is only necessary for flat tiles, because if the tile is @@ -223,8 +225,10 @@ /** Terraform land * @param tile tile to terraform + * @param flags for this command type * @param p1 corners to terraform. * @param p2 direction; eg up or down + * @return error or cost of terraforming */ int32 CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { @@ -346,8 +350,10 @@ /** 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 */ int32 CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { @@ -362,16 +368,16 @@ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - // remember level height + /* remember level height */ h = TileHeight(p1); - // make sure sx,sy are smaller than ex,ey + /* make sure sx,sy are smaller than ex,ey */ ex = TileX(tile); ey = TileY(tile); sx = TileX(p1); sy = TileY(p1); - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); tile = TileXY(sx, sy); size_x = ex-sx+1; @@ -405,8 +411,10 @@ /** 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 */ int32 CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { @@ -459,8 +467,10 @@ /** 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 */ int32 CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { @@ -787,17 +797,17 @@ } extern const TileTypeProcs _tile_type_clear_procs = { - DrawTile_Clear, /* draw_tile_proc */ - GetSlopeZ_Clear, /* get_slope_z_proc */ - ClearTile_Clear, /* clear_tile_proc */ - GetAcceptedCargo_Clear, /* get_accepted_cargo_proc */ - GetTileDesc_Clear, /* get_tile_desc_proc */ - GetTileTrackStatus_Clear, /* get_tile_track_status_proc */ - ClickTile_Clear, /* click_tile_proc */ - AnimateTile_Clear, /* animate_tile_proc */ - TileLoop_Clear, /* tile_loop_clear */ - ChangeTileOwner_Clear, /* change_tile_owner_clear */ - NULL, /* get_produced_cargo_proc */ - NULL, /* vehicle_enter_tile_proc */ - GetSlopeTileh_Clear, /* get_slope_tileh_proc */ + DrawTile_Clear, ///< draw_tile_proc + GetSlopeZ_Clear, ///< get_slope_z_proc + ClearTile_Clear, ///< clear_tile_proc + GetAcceptedCargo_Clear, ///< get_accepted_cargo_proc + GetTileDesc_Clear, ///< get_tile_desc_proc + GetTileTrackStatus_Clear, ///< get_tile_track_status_proc + ClickTile_Clear, ///< click_tile_proc + AnimateTile_Clear, ///< animate_tile_proc + TileLoop_Clear, ///< tile_loop_clear + ChangeTileOwner_Clear, ///< change_tile_owner_clear + NULL, ///< get_produced_cargo_proc + NULL, ///< vehicle_enter_tile_proc + GetSlopeTileh_Clear, ///< get_slope_tileh_proc }; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/clear_map.h --- a/src/clear_map.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/clear_map.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file clear_map.h */ + #ifndef CLEAR_MAP_H #define CLEAR_MAP_H @@ -11,12 +13,12 @@ * valid densities (bits 0...1) in comments after the enum */ typedef enum ClearGround { - CLEAR_GRASS = 0, // 0-3 - CLEAR_ROUGH = 1, // 3 - CLEAR_ROCKS = 2, // 3 - CLEAR_FIELDS = 3, // 3 - CLEAR_SNOW = 4, // 0-3 - CLEAR_DESERT = 5 // 1,3 + CLEAR_GRASS = 0, ///< 0-3 + CLEAR_ROUGH = 1, ///< 3 + CLEAR_ROCKS = 2, ///< 3 + CLEAR_FIELDS = 3, ///< 3 + CLEAR_SNOW = 4, ///< 0-3 + CLEAR_DESERT = 5 ///< 1,3 } ClearGround; @@ -134,7 +136,7 @@ _m[t].m3 = 0; _m[t].m4 = 0 << 5 | 0 << 2; SetClearGroundDensity(t, g, density); - SB(_m[t].m6, 2, 4, 0); ///< Clear the rest of m6, bits 2 to 5 + SB(_m[t].m6, 2, 4, 0); // Clear the rest of m6, bits 2 to 5 } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/cmd_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cmd_helper.h Wed Feb 28 00:33:40 2007 +0000 @@ -0,0 +1,28 @@ +/* $Id$ */ + +#ifndef CMD_HELPER_H +#define CMD_HELPER_H + +#include "direction.h" +#include "macros.h" +#include "road.h" + + +template static inline void ExtractValid(); +template<> static inline void ExtractValid<1>() {} + + +template struct ExtractBits; +template<> struct ExtractBits { static const uint Count = 1; }; +template<> struct ExtractBits { static const uint Count = 2; }; +template<> struct ExtractBits { static const uint Count = 4; }; + + +template static inline T Extract(U v) +{ + // Check if there are enough bits in v + ExtractValid::Count <= sizeof(U) * 8>(); + return (T)GB(v, N, ExtractBits::Count); +} + +#endif diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/command.cpp --- a/src/command.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/command.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file command.cpp */ + #include "stdafx.h" #include "openttd.h" #include "table/strings.h" @@ -347,7 +349,7 @@ _docommand_recursive++; - // only execute the test call if it's toplevel, or we're not execing. + /* only execute the test call if it's toplevel, or we're not execing. */ if (_docommand_recursive == 1 || !(flags & DC_EXEC) || (flags & DC_FORCETEST) ) { res = proc(tile, flags & ~DC_EXEC, p1, p2); if (CmdFailed(res)) { @@ -380,10 +382,10 @@ return CMD_ERROR; } - // if toplevel, subtract the money. + /* if toplevel, subtract the money. */ if (--_docommand_recursive == 0) { SubtractMoneyFromPlayer(res); - // XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of player + /* XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of player */ if (tile != 0 && IsValidPlayer(_current_player)) { GetPlayer(_current_player)->last_build_coordinate = tile; } @@ -400,8 +402,8 @@ return GetPlayer(pid)->player_money; } -// toplevel network safe docommand function for the current player. must not be called recursively. -// the callback is called when the command succeeded or failed. +/* toplevel network safe docommand function for the current player. must not be called recursively. + * the callback is called when the command succeeded or failed. */ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd) { int32 res = 0,res2; @@ -437,7 +439,7 @@ if (cmd & CMD_AUTO) flags |= DC_AUTO; if (cmd & CMD_NO_WATER) flags |= DC_NO_WATER; - // get pointer to command handler + /* get pointer to command handler */ assert((cmd & 0xFF) < lengthof(_command_proc_table)); proc = _command_proc_table[cmd & 0xFF].proc; if (proc == NULL) { @@ -445,15 +447,15 @@ return false; } - // Some commands have a different output in dryrun than the realrun - // 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 - // 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 - // fact will trigger an assertion failure. --pasky + /* Some commands have a different output in dryrun than the realrun + * 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 + * 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 + * fact will trigger an assertion failure. --pasky */ notest = (cmd & 0xFF) == CMD_CLEAR_AREA || (cmd & 0xFF) == CMD_CONVERT_RAIL || @@ -463,13 +465,13 @@ _docommand_recursive = 1; - // cost estimation only? + /* cost estimation only? */ if (!IsGeneratingWorld() && _shift_pressed && IsLocalPlayer() && !(cmd & (CMD_NETWORK_COMMAND | CMD_SHOW_NO_ERROR)) && (cmd & 0xFF) != CMD_PAUSE) { - // estimate the cost. + /* estimate the cost. */ res = proc(tile, flags, p1, p2); if (CmdFailed(res)) { if (res & 0xFFFF) _error_message = res & 0xFFFF; @@ -485,13 +487,13 @@ if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) { - // first test if the command can be executed. + /* first test if the command can be executed. */ res = proc(tile, flags, p1, p2); if (CmdFailed(res)) { if (res & 0xFFFF) _error_message = res & 0xFFFF; goto show_error; } - // no money? Only check if notest is off + /* no money? Only check if notest is off */ if (!notest && res != 0 && !CheckPlayerHasMoney(res)) goto show_error; } @@ -514,7 +516,7 @@ } #endif /* ENABLE_NETWORK */ - // update last build coordinate of player. + /* update last build coordinate of player. */ if (tile != 0 && IsValidPlayer(_current_player)) { GetPlayer(_current_player)->last_build_coordinate = tile; } @@ -524,8 +526,8 @@ _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 - // the real command.. so ignore the test + /* If notest is on, it means the result of the test can be different than + * the real command.. so ignore the test */ if (!notest && !((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) { assert(res == res2); // sanity check } else { @@ -553,7 +555,7 @@ return true; show_error: - // show error message if the command fails? + /* show error message if the command fails? */ if (IsLocalPlayer() && error_part1 != 0) { ShowErrorMessage(_error_message, error_part1, x,y); } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/command.h --- a/src/command.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/command.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file command.h */ + #ifndef COMMAND_H #define COMMAND_H @@ -122,8 +124,8 @@ CMD_MONEY_CHEAT = 102, CMD_BUILD_CANAL = 103, - CMD_PLAYER_CTRL = 104, // used in multiplayer to create a new player etc. - CMD_LEVEL_LAND = 105, // level land + CMD_PLAYER_CTRL = 104, ///< used in multiplayer to create a new player etc. + CMD_LEVEL_LAND = 105, ///< level land CMD_REFIT_RAIL_VEHICLE = 106, CMD_RESTORE_ORDER_INDEX = 107, @@ -145,13 +147,13 @@ enum { DC_EXEC = 0x01, - DC_AUTO = 0x02, // don't allow building on structures - DC_QUERY_COST = 0x04, // query cost only, don't build. - DC_NO_WATER = 0x08, // don't allow building on water - DC_NO_RAIL_OVERLAP = 0x10, // don't allow overlap of rails (used in buildrail) - DC_AI_BUILDING = 0x20, // special building rules for AI - DC_NO_TOWN_RATING = 0x40, // town rating does not disallow you from building - DC_FORCETEST = 0x80, // force test too. + DC_AUTO = 0x02, ///< don't allow building on structures + DC_QUERY_COST = 0x04, ///< query cost only, don't build. + DC_NO_WATER = 0x08, ///< don't allow building on water + DC_NO_RAIL_OVERLAP = 0x10, ///< don't allow overlap of rails (used in buildrail) + DC_AI_BUILDING = 0x20, ///< special building rules for AI + DC_NO_TOWN_RATING = 0x40, ///< town rating does not disallow you from building + DC_FORCETEST = 0x80, ///< force test too. CMD_ERROR = ((int32)0x80000000), }; @@ -161,17 +163,15 @@ enum { CMD_AUTO = 0x0200, CMD_NO_WATER = 0x0400, - CMD_NETWORK_COMMAND = 0x0800, // execute the command without sending it on the network - CMD_NO_TEST_IF_IN_NETWORK = 0x1000, // When enabled, the command will bypass the no-DC_EXEC round if in network + CMD_NETWORK_COMMAND = 0x0800, ///< execute the command without sending it on the network + CMD_NO_TEST_IF_IN_NETWORK = 0x1000, ///< When enabled, the command will bypass the no-DC_EXEC round if in network CMD_SHOW_NO_ERROR = 0x2000, }; -/** Command flags for the command table - * @see _command_proc_table - */ +/** Command flags for the command table _command_proc_table */ enum { - CMD_SERVER = 0x1, /// the command can only be initiated by the server - CMD_OFFLINE = 0x2, /// the command cannot be executed in a multiplayer game; single-player only + CMD_SERVER = 0x1, ///< the command can only be initiated by the server + CMD_OFFLINE = 0x2, ///< the command cannot be executed in a multiplayer game; single-player only }; typedef int32 CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2); @@ -191,11 +191,11 @@ */ static inline bool CmdFailed(int32 res) { - // lower 16bits are the StringID of the possible error + /* lower 16bits are the StringID of the possible error */ return res <= (CMD_ERROR | INVALID_STRING_ID); } -/* command.c */ +/* command.cpp */ typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2); int32 DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc); bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd); @@ -205,7 +205,7 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback); #endif /* ENABLE_NETWORK */ -extern const char* _cmd_text; // Text, which gets sent with a command +extern const char* _cmd_text; ///< Text, which gets sent with a command bool IsValidCommand(uint cmd); byte GetCommandFlags(uint cmd); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/console.cpp --- a/src/console.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/console.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file console.cpp */ + #include "stdafx.h" #include "openttd.h" #include "table/strings.h" @@ -26,23 +28,23 @@ #define ICON_MAX_ALIAS_LINES 40 #define ICON_TOKEN_COUNT 20 -// ** main console ** // +/* ** main console ** */ static char *_iconsole_buffer[ICON_BUFFER + 1]; static uint16 _iconsole_cbuffer[ICON_BUFFER + 1]; static Textbuf _iconsole_cmdline; -// ** stdlib ** // +/* ** stdlib ** */ byte _stdlib_developer = 1; bool _stdlib_con_developer = false; FILE *_iconsole_output_file; -// ** main console cmd buffer +/* ** main console cmd buffer ** */ static char *_iconsole_history[ICON_HISTORY_SIZE]; static byte _iconsole_historypos; -/* *************** */ -/* end of header */ -/* *************** */ +/* *************** * + * end of header * + * *************** */ static void IConsoleClearCommand(void) { @@ -60,7 +62,7 @@ static void IConsoleHistoryAdd(const char *cmd); static void IConsoleHistoryNavigate(int direction); -// ** console window ** // +/* ** console window ** */ static void IConsoleWndProc(BaseWindow *w, WindowEvent *e) { static byte iconsole_scroll = ICON_BUFFER; @@ -254,7 +256,7 @@ static void IConsoleWriteToLogFile(const char *string) { if (_iconsole_output_file != NULL) { - // if there is an console output file ... also print it there + /* if there is an console output file ... also print it there */ fwrite(string, strlen(string), 1, _iconsole_output_file); fwrite("\n", 1, 1, _iconsole_output_file); } @@ -337,7 +339,7 @@ { int i = _iconsole_historypos + direction; - // watch out for overflows, just wrap around + /* watch out for overflows, just wrap around */ if (i < 0) i = ICON_HISTORY_SIZE - 1; if (i >= ICON_HISTORY_SIZE) i = 0; @@ -350,7 +352,7 @@ _iconsole_historypos = i; IConsoleClearCommand(); - // copy history to 'command prompt / bash' + /* copy history to 'command prompt / bash' */ assert(_iconsole_history[i] != NULL && IS_INT_INSIDE(i, 0, ICON_HISTORY_SIZE)); ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxlength); UpdateTextBufferSize(&_iconsole_cmdline); @@ -478,9 +480,10 @@ return arg != endptr; } -// * ************************* * // -// * hooking code * // -// * ************************* * // +/* * ************************* + * hooking code * + * *************************/ + /** * General internal hooking code that is the same for both commands and variables * @param hooks @IConsoleHooks structure that will be set according to @@ -706,18 +709,18 @@ if (a_index >= lengthof(aliases) || astream_i >= lengthof(aliasstream)) break; switch (*cmdptr) { - case '\'': /* ' will double for "" */ + case '\'': // ' will double for "" aliasstream[astream_i++] = '"'; break; - case ';': /* Cmd seperator, start new command */ + case ';': // Cmd seperator, start new command aliasstream[astream_i] = '\0'; aliases[++a_index] = &aliasstream[++astream_i]; cmdptr++; break; - case '%': /* Some or all parameters */ + case '%': // Some or all parameters cmdptr++; switch (*cmdptr) { - case '+': { /* All parameters seperated: "[param 1]" "[param 2]" */ + case '+': { // All parameters seperated: "[param 1]" "[param 2]" for (i = 0; i != tokencount; i++) { aliasstream[astream_i++] = '"'; astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[i], astream_i); @@ -725,7 +728,7 @@ aliasstream[astream_i++] = ' '; } } break; - case '!': { /* Merge the parameters to one: "[param 1] [param 2] [param 3...]" */ + case '!': { // Merge the parameters to one: "[param 1] [param 2] [param 3...]" aliasstream[astream_i++] = '"'; for (i = 0; i != tokencount; i++) { astream_i += IConsoleCopyInParams(&aliasstream[astream_i], tokens[i], astream_i); @@ -734,7 +737,7 @@ aliasstream[astream_i++] = '"'; } break; - default: { /* One specific parameter: %A = [param 1] %B = [param 2] ... */ + default: { // One specific parameter: %A = [param 1] %B = [param 2] ... int param = *cmdptr - 'A'; if (param < 0 || param >= tokencount) { @@ -1083,16 +1086,16 @@ tstream_i++; break; - case '"': /* Tokens enclosed in "" are one token */ + case '"': // Tokens enclosed in "" are one token longtoken = !longtoken; break; - case '\\': /* Escape character for "" */ + case '\\': // Escape character for "" if (cmdptr[1] == '"' && tstream_i + 1 < lengthof(tokenstream)) { tokenstream[tstream_i++] = *++cmdptr; break; } /* fallthrough */ - default: /* Normal character */ + default: // Normal character tokenstream[tstream_i++] = *cmdptr; if (!foundtoken) { diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/console.h --- a/src/console.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/console.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,11 +1,13 @@ /* $Id$ */ +/** @file console.h */ + #ifndef CONSOLE_H #define CONSOLE_H -// maximum length of a typed in command +/* maximum length of a typed in command */ #define ICON_CMDLN_SIZE 255 -// maximum length of a totally expanded command +/* maximum length of a totally expanded command */ #define ICON_MAX_STREAMSIZE 1024 typedef enum IConsoleVarTypes { @@ -37,9 +39,9 @@ */ typedef bool IConsoleHook(void); typedef struct IConsoleHooks{ - IConsoleHook *access; // trigger when accessing the variable/command - IConsoleHook *pre; // trigger before the variable/command is changed/executed - IConsoleHook *post; // trigger after the variable/command is changed/executed + IConsoleHook *access; ///< trigger when accessing the variable/command + IConsoleHook *pre; ///< trigger before the variable/command is changed/executed + IConsoleHook *post; ///< trigger after the variable/command is changed/executed } IConsoleHooks; /** --Commands-- @@ -53,11 +55,11 @@ struct IConsoleCmd; typedef struct IConsoleCmd { - char *name; // name of command - struct IConsoleCmd *next; // next command in list + char *name; ///< name of command + struct IConsoleCmd *next; ///< next command in list - IConsoleCmdProc *proc; // process executed when command is typed - IConsoleHooks hook; // any special trigger action that needs executing + IConsoleCmdProc *proc; ///< process executed when command is typed + IConsoleHooks hook; ///< any special trigger action that needs executing } IConsoleCmd; /** --Variables-- @@ -71,15 +73,15 @@ */ struct IConsoleVar; typedef struct IConsoleVar { - char *name; // name of the variable - struct IConsoleVar *next; // next variable in list + char *name; ///< name of the variable + struct IConsoleVar *next; ///< next variable in list - void *addr; // the address where the variable is pointing at - uint32 size; // size of the variable, used for strings - char *help; // the optional help string shown when requesting information - IConsoleVarTypes type; // type of variable (for correct assignment/output) - IConsoleCmdProc *proc; // some variables need really special handling, use a callback function for that - IConsoleHooks hook; // any special trigger action that needs executing + void *addr; ///< the address where the variable is pointing at + uint32 size; ///< size of the variable, used for strings + char *help; ///< the optional help string shown when requesting information + IConsoleVarTypes type; ///< type of variable (for correct assignment/output) + IConsoleCmdProc *proc; ///< some variables need really special handling, use a callback function for that + IConsoleHooks hook; ///< any special trigger action that needs executing } IConsoleVar; /** --Aliases-- @@ -95,16 +97,16 @@ */ struct IConsoleAlias; typedef struct IConsoleAlias { - char *name; // name of the alias - struct IConsoleAlias *next; // next alias in list + char *name; ///< name of the alias + struct IConsoleAlias *next; ///< next alias in list - char *cmdline; // command(s) that is/are being aliased + char *cmdline; ///< command(s) that is/are being aliased } 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 +VARDEF IConsoleCmd *_iconsole_cmds; ///< list of registred commands +VARDEF IConsoleVar *_iconsole_vars; ///< list of registred vars +VARDEF IConsoleAlias *_iconsole_aliases; ///< list of registred aliases /* console colors/modes */ VARDEF byte _icolour_def; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/console_cmds.cpp --- a/src/console_cmds.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/console_cmds.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file console_cmds.cpp */ + #include "stdafx.h" #include "openttd.h" #include "console.h" @@ -226,7 +228,7 @@ if (strcmp(file, _fios_list[i].title) == 0) break; } - if (i == _fios_num) { /* If no name matches, try to parse it as number */ + if (i == _fios_num) { // If no name matches, try to parse it as number char* endptr; i = strtol(file, &endptr, 10); @@ -614,7 +616,7 @@ DEF_CONSOLE_HOOK(ConHookValidateMaxSpectatorsCount) { - /* XXX @see ConHookValidateMaxClientsCount */ + /* XXX see ConHookValidateMaxClientsCount */ if (_network_game_info.spectators_max > 10) { _network_game_info.spectators_max = 10; IConsoleError("Maximum spectators out of bounds, truncating to limit."); @@ -1342,7 +1344,7 @@ if (ci == NULL) return false; - // Don't change the name if it is the same as the old name + /* Don't change the name if it is the same as the old name */ if (strcmp(ci->client_name, _network_player_name) != 0) { if (!_network_server) { SEND_COMMAND(PACKET_CLIENT_SET_NAME)(_network_player_name); @@ -1441,8 +1443,8 @@ static void IConsoleDebugLibRegister(void) { - // debugging variables and functions - extern bool _stdlib_con_developer; /* XXX extern in .c */ + /* debugging variables and functions */ + extern bool _stdlib_con_developer; // XXX extern in .cpp IConsoleVarRegister("con_developer", &_stdlib_con_developer, ICONSOLE_VAR_BOOLEAN, "Enable/disable console debugging information (internal)"); IConsoleCmdRegister("resettile", ConResetTile); @@ -1458,10 +1460,10 @@ void IConsoleStdLibRegister(void) { - // stdlib - extern byte _stdlib_developer; /* XXX extern in .c */ + /* stdlib */ + extern byte _stdlib_developer; // XXX extern in .cpp - // default variables and functions + /* default variables and functions */ IConsoleCmdRegister("debug_level", ConDebugLevel); IConsoleCmdRegister("dump_vars", ConListDumpVariables); IConsoleCmdRegister("echo", ConEcho); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/currency.cpp --- a/src/currency.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/currency.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file currency.cpp **/ + #include "stdafx.h" #include "openttd.h" #include "currency.h" @@ -13,34 +15,34 @@ // | | Euro year | | | name // | | | | | | | static const CurrencySpec origin_currency_specs[NUM_CURRENCY] = { - { 1, ',', CF_NOEURO, "£", "", 0, STR_CURR_GBP }, // british pounds - { 2, ',', CF_NOEURO, "$", "", 0, STR_CURR_USD }, // us dollars - { 2, ',', CF_ISEURO, "€", "", 0, STR_CURR_EUR }, // Euro - { 220, ',', CF_NOEURO, "Â¥", "", 0, STR_CURR_YEN }, // yen - { 20, ',', 2002, "", " S.", 1, STR_CURR_ATS }, // austrian schilling - { 59, ',', 2002, "BEF ", "", 0, STR_CURR_BEF }, // belgian franc - { 2, ',', CF_NOEURO, "CHF ", "", 0, STR_CURR_CHF }, // swiss franc - { 41, ',', CF_NOEURO, "", " KÄ", 1, STR_CURR_CZK }, // czech koruna - { 3, '.', 2002, "DM ", "", 0, STR_CURR_DEM }, // deutsche mark - { 11, '.', CF_NOEURO, "", " kr", 1, STR_CURR_DKK }, // danish krone - { 245, '.', 2002, "Pts ", "", 0, STR_CURR_ESP }, // spanish pesetas - { 9, ',', 2002, "", " mk", 1, STR_CURR_FIM }, // finnish markka - { 10, '.', 2002, "FF ", "", 0, STR_CURR_FRF }, // french francs - { 500, ',', 2002, "", "Dr.", 1, STR_CURR_GRD }, // greek drachma - { 378, ',', 2010, "", " Ft", 1, STR_CURR_HUF }, // hungarian forint - { 130, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_ISK }, // icelandic krona - { 2850, ',', 2002, "", " L.", 1, STR_CURR_ITL }, // italian lira - { 3, ',', 2002, "NLG ", "", 0, STR_CURR_NLG }, // dutch gulden - { 12, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_NOK }, // norwegian krone - { 6, ' ', CF_NOEURO, "", " zl", 1, STR_CURR_PLN }, // polish zloty - { 5, '.', CF_NOEURO, "", " Lei", 1, STR_CURR_ROL }, // romanian Lei - { 50, ' ', CF_NOEURO, "", " p", 1, STR_CURR_RUR }, // russian rouble - { 352, '.', CF_NOEURO, "", " SIT", 1, STR_CURR_SIT }, // slovenian tolar - { 13, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_SEK }, // swedish krona - { 3, '.', CF_NOEURO, "", " YTL", 1, STR_CURR_YTL }, // turkish lira - { 52, ',', CF_NOEURO, "", " Sk", 1, STR_CURR_SKK }, // slovak koruna - { 4, ',', CF_NOEURO, "R$ ", "", 0, STR_CURR_BRR }, // brazil real - { 1, ' ', CF_NOEURO, "", "", 2, STR_CURR_CUSTOM }, // custom currency + { 1, ',', CF_NOEURO, "£", "", 0, STR_CURR_GBP }, ///< british pounds + { 2, ',', CF_NOEURO, "$", "", 0, STR_CURR_USD }, ///< us dollars + { 2, ',', CF_ISEURO, "€", "", 0, STR_CURR_EUR }, ///< Euro + { 220, ',', CF_NOEURO, "Â¥", "", 0, STR_CURR_YEN }, ///< yen + { 20, ',', 2002, "", " S.", 1, STR_CURR_ATS }, ///< austrian schilling + { 59, ',', 2002, "BEF ", "", 0, STR_CURR_BEF }, ///< belgian franc + { 2, ',', CF_NOEURO, "CHF ", "", 0, STR_CURR_CHF }, ///< swiss franc + { 41, ',', CF_NOEURO, "", " KÄ", 1, STR_CURR_CZK }, ///< czech koruna + { 3, '.', 2002, "DM ", "", 0, STR_CURR_DEM }, ///< deutsche mark + { 11, '.', CF_NOEURO, "", " kr", 1, STR_CURR_DKK }, ///< danish krone + { 245, '.', 2002, "Pts ", "", 0, STR_CURR_ESP }, ///< spanish pesetas + { 9, ',', 2002, "", " mk", 1, STR_CURR_FIM }, ///< finnish markka + { 10, '.', 2002, "FF ", "", 0, STR_CURR_FRF }, ///< french francs + { 500, ',', 2002, "", "Dr.", 1, STR_CURR_GRD }, ///< greek drachma + { 378, ',', 2010, "", " Ft", 1, STR_CURR_HUF }, ///< hungarian forint + { 130, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_ISK }, ///< icelandic krona + { 2850, ',', 2002, "", " L.", 1, STR_CURR_ITL }, ///< italian lira + { 3, ',', 2002, "NLG ", "", 0, STR_CURR_NLG }, ///< dutch gulden + { 12, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_NOK }, ///< norwegian krone + { 6, ' ', CF_NOEURO, "", " zl", 1, STR_CURR_PLN }, ///< polish zloty + { 5, '.', CF_NOEURO, "", " Lei", 1, STR_CURR_ROL }, ///< romanian Lei + { 50, ' ', CF_NOEURO, "", " p", 1, STR_CURR_RUR }, ///< russian rouble + { 352, '.', CF_NOEURO, "", " SIT", 1, STR_CURR_SIT }, ///< slovenian tolar + { 13, '.', CF_NOEURO, "", " Kr", 1, STR_CURR_SEK }, ///< swedish krona + { 3, '.', CF_NOEURO, "", " YTL", 1, STR_CURR_YTL }, ///< turkish lira + { 52, ',', CF_NOEURO, "", " Sk", 1, STR_CURR_SKK }, ///< slovak koruna + { 4, ',', CF_NOEURO, "R$ ", "", 0, STR_CURR_BRR }, ///< brazil real + { 1, ' ', CF_NOEURO, "", "", 2, STR_CURR_CUSTOM }, ///< custom currency }; /* Array of currencies used by the system */ @@ -122,7 +124,10 @@ return (grfcurr_id >= lengthof(TTDPatch_To_OTTDIndex)) ? grfcurr_id : TTDPatch_To_OTTDIndex[grfcurr_id]; } -/* get a mask of the allowed currencies depending on the year */ +/** + * get a mask of the allowed currencies depending on the year + * @return mask of currencies + */ uint GetMaskOfAllowedCurrencies(void) { uint mask = 0; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/currency.h --- a/src/currency.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/currency.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file currency.h */ + #ifndef CURRENCY_H #define CURRENCY_H diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/date.cpp --- a/src/date.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/date.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file date.cpp */ + #include "stdafx.h" #include "openttd.h" #include "date.h" @@ -197,11 +199,11 @@ static const Month _autosave_months[] = { - 0, // never - 1, // every month - 3, // every 3 months - 6, // every 6 months - 12, // every 12 months + 0, ///< never + 1, ///< every month + 3, ///< every 3 months + 6, ///< every 6 months + 12, ///< every 12 months }; /** diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/date.h --- a/src/date.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/date.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file date.h */ + #ifndef DATE_H #define DATE_H diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/debug.cpp --- a/src/debug.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/debug.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file debug.cpp */ + #include "stdafx.h" #include #include @@ -105,7 +107,7 @@ char *end; const char *t; - // global debugging level? + /* global debugging level? */ if (*s >= '0' && *s <= '9') { const DebugLevel *i; @@ -115,19 +117,19 @@ for (i = debug_level; i != endof(debug_level); ++i) *i->level = v; } - // individual levels + /* individual levels */ for (;;) { const DebugLevel *i; int *p; - // skip delimiters + /* skip delimiters */ while (*s == ' ' || *s == ',' || *s == '\t') s++; if (*s == '\0') break; t = s; while (*s >= 'a' && *s <= 'z') s++; - // check debugging levels + /* check debugging levels */ p = NULL; for (i = debug_level; i != endof(debug_level); ++i) if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) { diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/dedicated.cpp --- a/src/dedicated.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/dedicated.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file dedicated.cpp */ + #include "stdafx.h" #ifdef ENABLE_NETWORK @@ -43,7 +45,7 @@ } default: - // We're the parent + /* We're the parent */ printf("Loading dedicated server...\n"); printf(" - Forked to background with pid %d\n", pid); exit(0); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/depot.cpp --- a/src/depot.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/depot.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file depot.cpp */ + #include "stdafx.h" #include "openttd.h" #include "depot.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/depot.h --- a/src/depot.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/depot.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,11 +1,10 @@ /* $Id$ */ +/** @file depot.h Header files for depots (not hangars) */ + #ifndef DEPOT_H #define DEPOT_H -/** @file depot.h Header files for depots (not hangars) - * @see depot.c */ - #include "direction.h" #include "oldpool.h" #include "tile.h" @@ -55,6 +54,7 @@ * 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) { @@ -85,7 +85,7 @@ /** * Find out if the slope of the tile is suitable to build a depot of given direction - * @param direction The direction in which the depot's exit points. Starts with 0 as NE and goes Clockwise + * @param direction The direction in which the depot's exit points * @param tileh The slope of the tile in question * @return true if the construction is possible @@ -98,7 +98,7 @@ * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001

    * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh */ -static inline bool CanBuildDepotByTileh(uint32 direction, Slope tileh) +static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh) { return ((0x4C >> direction) & tileh) != 0; } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/depot_gui.cpp --- a/src/depot_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/depot_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** depot_gui.cpp */ + #include "stdafx.h" #include "openttd.h" #include "functions.h" @@ -36,8 +38,8 @@ DEPOT_WIDGET_SELL_ALL, DEPOT_WIDGET_AUTOREPLACE, DEPOT_WIDGET_MATRIX, - DEPOT_WIDGET_V_SCROLL, // Vertical scrollbar - DEPOT_WIDGET_H_SCROLL, // Horizontal scrollbar + DEPOT_WIDGET_V_SCROLL, ///< Vertical scrollbar + DEPOT_WIDGET_H_SCROLL, ///< Horizontal scrollbar DEPOT_WIDGET_BUILD, DEPOT_WIDGET_CLONE, DEPOT_WIDGET_LOCATION, @@ -636,7 +638,7 @@ /* Array to hold the default resize capacities * First part is the vehicle type, while the last is 0 = x, 1 = y */ const uint _resize_cap[][2] = { -/* VEH_Train */ {6, 10 * 29 + 36}, // flags, unitnumber and unit count uses a total of 36 pixels and we set default to 10 units +/* VEH_Train */ {6, 10 * 29 + 36}, ///< flags, unitnumber and unit count uses a total of 36 pixels and we set default to 10 units /* VEH_Road */ {5, 5}, /* VEH_Ship */ {3, 3}, /* VEH_Aircraft */ {3, 4}, diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/direction.h --- a/src/direction.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/direction.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file direction.h */ + #ifndef DIRECTION_H #define DIRECTION_H @@ -9,7 +11,7 @@ typedef enum Direction { DIR_BEGIN = 0, DIR_N = 0, - DIR_NE = 1, /* Northeast, upper right on your monitor */ + DIR_NE = 1, ///< Northeast, upper right on your monitor DIR_E = 2, DIR_SE = 3, DIR_S = 4, @@ -59,7 +61,7 @@ /* Direction commonly used as the direction of entering and leaving tiles, 4-way */ typedef enum DiagDirection { DIAGDIR_BEGIN = 0, - DIAGDIR_NE = 0, /* Northeast, upper right on your monitor */ + DIAGDIR_NE = 0, ///< Northeast, upper right on your monitor DIAGDIR_SE = 1, DIAGDIR_SW = 2, DIAGDIR_NW = 3, diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/disaster_cmd.cpp --- a/src/disaster_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/disaster_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,6 +1,6 @@ /* $Id$ */ -/** @file +/** @file disaster_cmd.cpp * All disaster/easter egg vehicles are handled here. * The general flow of control for the disaster vehicles is as follows: *

      @@ -99,13 +99,13 @@ static const SpriteID _disaster_images_9[] = {SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1, SPR_ROTOR_MOVING_1}; static const SpriteID * const _disaster_images[] = { - _disaster_images_1, _disaster_images_1, // zeppeliner and zeppeliner shadow - _disaster_images_2, _disaster_images_2, // small ufo and small ufo shadow - _disaster_images_3, _disaster_images_3, // combat aircraft and shadow - _disaster_images_8, _disaster_images_8, _disaster_images_9, // combat helicopter, shadow and rotor - _disaster_images_6, _disaster_images_6, // big ufo and shadow - _disaster_images_7, _disaster_images_7, // skyranger and shadow - _disaster_images_4, _disaster_images_5, // small and big submarine sprites + _disaster_images_1, _disaster_images_1, ///< zeppeliner and zeppeliner shadow + _disaster_images_2, _disaster_images_2, ///< small ufo and small ufo shadow + _disaster_images_3, _disaster_images_3, ///< combat aircraft and shadow + _disaster_images_8, _disaster_images_8, _disaster_images_9, ///< combat helicopter, shadow and rotor + _disaster_images_6, _disaster_images_6, ///< big ufo and shadow + _disaster_images_7, _disaster_images_7, ///< skyranger and shadow + _disaster_images_4, _disaster_images_5, ///< small and big submarine sprites }; static void DisasterVehicleUpdateImage(Vehicle *v) @@ -200,7 +200,6 @@ */ static void DisasterTick_Zeppeliner(Vehicle *v) { - GetNewVehiclePosResult gp; Station *st; int x, y; byte z; @@ -211,7 +210,7 @@ if (v->current_order.dest < 2) { if (HASBIT(v->tick_counter, 0)) return; - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); @@ -308,7 +307,6 @@ */ static void DisasterTick_Ufo(Vehicle *v) { - GetNewVehiclePosResult gp; Vehicle *u; uint dist; byte z; @@ -321,7 +319,7 @@ int y = TileY(v->dest_tile) * TILE_SIZE; if (delta(x, v->x_pos) + delta(y, v->y_pos) >= TILE_SIZE) { v->direction = GetDirectionTowards(v, x, y); - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); return; } @@ -356,7 +354,7 @@ } v->direction = GetDirectionTowards(v, u->x_pos, u->y_pos); - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); z = v->z_pos; if (dist <= TILE_SIZE && z > u->z_pos) z--; @@ -406,13 +404,11 @@ */ static void DisasterTick_Airplane(Vehicle *v) { - GetNewVehiclePosResult gp; - v->tick_counter++; v->u.disaster.image_override = (v->current_order.dest == 1 && HASBIT(v->tick_counter, 2)) ? SPR_F_15_FIRING : 0; - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); if (gp.x < (-10 * TILE_SIZE)) { @@ -481,13 +477,11 @@ */ static void DisasterTick_Helicopter(Vehicle *v) { - GetNewVehiclePosResult gp; - v->tick_counter++; v->u.disaster.image_override = (v->current_order.dest == 1 && HASBIT(v->tick_counter, 2)) ? SPR_AH_64A_FIRING : 0; - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); if (gp.x > (int)MapSizeX() * TILE_SIZE + 9 * TILE_SIZE - 1) { @@ -568,7 +562,6 @@ */ static void DisasterTick_Big_Ufo(Vehicle *v) { - GetNewVehiclePosResult gp; byte z; Vehicle *u, *w; Town *t; @@ -583,7 +576,7 @@ if (delta(v->x_pos, x) + delta(v->y_pos, y) >= 8) { v->direction = GetDirectionTowards(v, x, y); - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); return; } @@ -632,7 +625,7 @@ int y = TileY(v->dest_tile) * TILE_SIZE; if (delta(x, v->x_pos) + delta(y, v->y_pos) >= TILE_SIZE) { v->direction = GetDirectionTowards(v, x, y); - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); return; } @@ -665,13 +658,12 @@ */ static void DisasterTick_Big_Ufo_Destroyer(Vehicle *v) { - GetNewVehiclePosResult gp; Vehicle *u; int i; v->tick_counter++; - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); if (gp.x > (int)MapSizeX() * TILE_SIZE + 9 * TILE_SIZE - 1) { @@ -711,7 +703,6 @@ */ static void DisasterTick_Submarine(Vehicle *v) { - GetNewVehiclePosResult gp; TileIndex tile; v->tick_counter++; @@ -731,7 +722,7 @@ TrackdirBits r = (TrackdirBits)GetTileTrackStatus(tile, TRANSPORT_WATER); if (TrackdirBitsToTrackBits(r) == TRACK_BIT_ALL && !CHANCE16(1, 90)) { - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); SetDisasterVehiclePos(v, gp.x, gp.y, v->z_pos); return; } @@ -1029,14 +1020,14 @@ Year min; Year max; } _dis_years[] = { - { 1930, 1955 }, // zeppeliner - { 1940, 1970 }, // ufo (small) - { 1960, 1990 }, // airplane - { 1970, 2000 }, // helicopter - { 2000, 2100 }, // ufo (big) - { 1940, 1965 }, // submarine (small) - { 1975, 2010 }, // submarine (big) - { 1950, 1985 } // coalmine + { 1930, 1955 }, ///< zeppeliner + { 1940, 1970 }, ///< ufo (small) + { 1960, 1990 }, ///< airplane + { 1970, 2000 }, ///< helicopter + { 2000, 2100 }, ///< ufo (big) + { 1940, 1965 }, ///< submarine (small) + { 1975, 2010 }, ///< submarine (big) + { 1950, 1985 } ///< coalmine }; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/dock_gui.cpp --- a/src/dock_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/dock_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file dock_gui.cpp */ + #include "stdafx.h" #include "openttd.h" #include "table/sprites.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/driver.cpp --- a/src/driver.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/driver.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file driver.cpp */ + #include "stdafx.h" #include "openttd.h" #include "debug.h" @@ -143,13 +145,13 @@ char buffer[256]; const char* parms[32]; - // Extract the driver name and put parameter list in parm + /* Extract the driver name and put parameter list in parm */ ttd_strlcpy(buffer, name, sizeof(buffer)); parm = strchr(buffer, ':'); parms[0] = NULL; if (parm != NULL) { uint np = 0; - // Tokenize the parm. + /* Tokenize the parm. */ do { *parm++ = '\0'; if (np < lengthof(parms) - 1) diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/driver.h --- a/src/driver.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/driver.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file driver.h */ + #ifndef DRIVER_H #define DRIVER_H diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/dummy_land.cpp --- a/src/dummy_land.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/dummy_land.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file dummy_land.cpp */ + #include "stdafx.h" #include "openttd.h" #include "table/strings.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/economy.cpp --- a/src/economy.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/economy.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file economy.cpp */ + #include "stdafx.h" #include "openttd.h" #include "currency.h" @@ -33,8 +35,9 @@ #include "newgrf_callbacks.h" #include "unmovable.h" #include "date.h" +#include "cargotype.h" -// Score info +/* Score info */ const ScoreInfo _score_info[] = { { SCORE_VEHICLES, 120, 100 }, { SCORE_STATIONS, 80, 100 }, @@ -89,8 +92,12 @@ return max(value, 1LL); } -// if update is set to true, the economy is updated with this score -// (also the house is updated, should only be true in the on-tick event) +/** if update is set to true, the economy is updated with this score + * (also the house is updated, should only be true in the on-tick event) + * @param update the economy with calculated score + * @param p player been evaluated + * @return actual score of this player + * */ int UpdateCompanyRatingAndValue(Player *p, bool update) { byte owner = p->index; @@ -208,15 +215,15 @@ _score_part[owner][SCORE_LOAN] = _score_info[SCORE_LOAN].needed - p->current_loan; } - // Now we calculate the score for each item.. + /* Now we calculate the score for each item.. */ { int total_score = 0; int s; score = 0; for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) { - // Skip the total + /* Skip the total */ if (i == SCORE_TOTAL) continue; - // Check the score + /* Check the score */ s = (_score_part[owner][i] >= _score_info[i].needed) ? _score_info[i].score : _score_part[owner][i] * _score_info[i].score / _score_info[i].needed; @@ -227,7 +234,7 @@ _score_part[owner][SCORE_TOTAL] = score; - // We always want the score scaled to SCORE_MAX (1000) + /* We always want the score scaled to SCORE_MAX (1000) */ if (total_score != SCORE_MAX) score = score * SCORE_MAX / total_score; } @@ -241,7 +248,7 @@ return score; } -// use PLAYER_SPECTATOR as new_player to delete the player. +/* use PLAYER_SPECTATOR as new_player to delete the player. */ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player) { Town *t; @@ -293,7 +300,7 @@ int num_aircraft = 0; Vehicle *v; - // Determine Ids for the new vehicles + /* Determine Ids for the new vehicles */ FOR_ALL_VEHICLES(v) { if (v->owner == new_player) { switch (v->type) { @@ -327,7 +334,7 @@ } } - // Change ownership of tiles + /* Change ownership of tiles */ { TileIndex tile = 0; do { @@ -367,7 +374,7 @@ PlayerID owner; int64 val; - // If the player has money again, it does not go bankrupt + /* If the player has money again, it does not go bankrupt */ if (p->player_money >= 0) { p->quarters_of_bankrupcy = 0; return; @@ -391,8 +398,8 @@ break; } - // Check if the company has any value.. if not, declare it bankrupt - // right now + /* Check if the company has any value.. if not, declare it bankrupt + * right now */ val = CalculateCompanyValue(p); if (val > 0) { p->bankrupt_value = val; @@ -400,13 +407,13 @@ p->bankrupt_timeout = 0; break; } - // Else, falltrue to case 4... + /* Else, falltrue to case 4... */ } case 4: { - // Close everything the owner has open + /* Close everything the owner has open */ DeletePlayerWindows(owner); -// Show bankrupt news + /* Show bankrupt news */ SetDParam(0, p->name_1); SetDParam(1, p->name_2); AddNewsItem( (StringID)(owner | NB_BBANKRUPT), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0); @@ -612,19 +619,21 @@ static void AddSingleInflation(int32 *value, uint16 *frac, int32 amt) { - int64 tmp; - int32 low; - tmp = BIGMULS(*value, amt); - *frac = (uint16)(low = (uint16)tmp + *frac); - *value += (int32)(tmp >> 16) + (low >> 16); + int64 tmp = (int64)*value * amt + *frac; + *frac = GB(tmp, 0, 16); + *value += tmp >> 16; } static void AddInflation(void) { - int i; + /* Approximation for (100 + infl_amount)% ** (1 / 12) - 100% + * scaled by 65536 + * 12 -> months per year + * This is only a good approxiamtion for small values + */ int32 inf = _economy.infl_amount * 54; - for (i = 0; i != NUM_PRICES; i++) { + for (uint i = 0; i != NUM_PRICES; i++) { AddSingleInflation((int32*)&_price + i, _price_frac + i, inf); } @@ -634,7 +643,7 @@ _economy.max_loan += 50000; inf = _economy.infl_amount_pr * 54; - for (i = 0; i != NUM_CARGO; i++) { + for (uint i = 0; i != NUM_CARGO; i++) { AddSingleInflation( (int32*)_cargo_payment_rates + i, _cargo_payment_rates_frac + i, @@ -690,55 +699,55 @@ }; static const int32 _price_base[NUM_PRICES] = { - 100, // station_value - 100, // build_rail - 95, // build_road - 65, // build_signals - 275, // build_bridge - 600, // build_train_depot - 500, // build_road_depot - 700, // build_ship_depot - 450, // build_tunnel - 200, // train_station_track - 180, // train_station_length - 600, // build_airport - 200, // build_bus_station - 200, // build_truck_station - 350, // build_dock - 400000, // build_railvehicle - 2000, // build_railwagon - 700000, // aircraft_base - 14000, // roadveh_base - 65000, // ship_base - 20, // build_trees - 250, // terraform - 20, // clear_1 - 40, // purchase_land - 200, // clear_2 - 500, // clear_3 - 20, // remove_trees - -70, // remove_rail - 10, // remove_signals - 50, // clear_bridge - 80, // remove_train_depot - 80, // remove_road_depot - 90, // remove_ship_depot - 30, // clear_tunnel - 10000, // clear_water - 50, // remove_rail_station - 30, // remove_airport - 50, // remove_bus_station - 50, // remove_truck_station - 55, // remove_dock - 1600, // remove_house - 40, // remove_road - 5600, // running_rail[0] railroad - 5200, // running_rail[1] monorail - 4800, // running_rail[2] maglev - 9600, // aircraft_running - 1600, // roadveh_running - 5600, // ship_running - 1000000, // build_industry + 100, ///< station_value + 100, ///< build_rail + 95, ///< build_road + 65, ///< build_signals + 275, ///< build_bridge + 600, ///< build_train_depot + 500, ///< build_road_depot + 700, ///< build_ship_depot + 450, ///< build_tunnel + 200, ///< train_station_track + 180, ///< train_station_length + 600, ///< build_airport + 200, ///< build_bus_station + 200, ///< build_truck_station + 350, ///< build_dock + 400000, ///< build_railvehicle + 2000, ///< build_railwagon + 700000, ///< aircraft_base + 14000, ///< roadveh_base + 65000, ///< ship_base + 20, ///< build_trees + 250, ///< terraform + 20, ///< clear_1 + 40, ///< purchase_land + 200, ///< clear_2 + 500, ///< clear_3 + 20, ///< remove_trees + -70, ///< remove_rail + 10, ///< remove_signals + 50, ///< clear_bridge + 80, ///< remove_train_depot + 80, ///< remove_road_depot + 90, ///< remove_ship_depot + 30, ///< clear_tunnel + 10000, ///< clear_water + 50, ///< remove_rail_station + 30, ///< remove_airport + 50, ///< remove_bus_station + 50, ///< remove_truck_station + 55, ///< remove_dock + 1600, ///< remove_house + 40, ///< remove_road + 5600, ///< running_rail[0] railroad + 5200, ///< running_rail[1] monorail + 4800, ///< running_rail[2] maglev + 9600, ///< aircraft_running + 1600, ///< roadveh_running + 5600, ///< ship_running + 1000000, ///< build_industry }; static byte price_base_multiplier[NUM_PRICES]; @@ -750,7 +759,7 @@ { uint i; - // 8 means no multiplier. + /* 8 means no multiplier. */ for (i = 0; i < NUM_PRICES; i++) price_base_multiplier[i] = 8; } @@ -807,7 +816,8 @@ Pair tp; /* if mode is false, use the singular form */ - SetDParam(0, _cargoc.names_s[s->cargo_type] + (mode ? 0 : 32)); + const CargoSpec *cs = GetCargo(s->cargo_type); + SetDParam(0, mode ? cs->name_plural : cs->name); if (s->age < 12) { if (s->cargo_type != CT_PASSENGERS && s->cargo_type != CT_MAIL) { @@ -924,7 +934,7 @@ fr->from = i = GetRandomIndustry(); if (i == NULL) return; - // Randomize cargo type + /* Randomize cargo type */ if (Random()&1 && i->produced_cargo[1] != CT_INVALID) { cargo = i->produced_cargo[1]; trans = i->pct_transported[1]; @@ -935,28 +945,28 @@ total = i->total_production[0]; } - // Quit if no production in this industry - // or if the cargo type is passengers - // or if the pct transported is already large enough + /* Quit if no production in this industry + * or if the cargo type is passengers + * or if the pct transported is already large enough */ if (total == 0 || trans > 42 || cargo == CT_INVALID || cargo == CT_PASSENGERS) return; fr->cargo = cargo; if (cargo == CT_GOODS || cargo == CT_FOOD) { - // The destination is a town + /* The destination is a town */ Town *t = GetRandomTown(); - // Only want big towns + /* Only want big towns */ if (t == NULL || t->population < 900) return; fr->distance = DistanceManhattan(i->xy, t->xy); fr->to = t; } else { - // The destination is an industry + /* The destination is an industry */ Industry *i2 = GetRandomIndustry(); - // The industry must accept the cargo + /* The industry must accept the cargo */ if (i == i2 || i == NULL || (cargo != i2->accepts_cargo[0] && cargo != i2->accepts_cargo[1] && @@ -1014,9 +1024,9 @@ } } - // 25% chance to go on + /* 25% chance to go on */ if (CHANCE16(1,4)) { - // Find a free slot + /* Find a free slot*/ s = _subsidies; while (s->cargo_type != CT_INVALID) { if (++s == endof(_subsidies)) @@ -1087,6 +1097,7 @@ int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type) { CargoID cargo = cargo_type; + const CargoSpec *cs = GetCargo(cargo_type); byte f; /* zero the distance if it's the bank and very short transport. */ @@ -1094,12 +1105,12 @@ dist = 0; f = 255; - if (transit_days > _cargoc.transit_days_1[cargo]) { - transit_days -= _cargoc.transit_days_1[cargo]; + if (transit_days > cs->transit_days[0]) { + transit_days -= cs->transit_days[0]; f -= transit_days; - if (transit_days > _cargoc.transit_days_2[cargo]) { - transit_days -= _cargoc.transit_days_2[cargo]; + if (transit_days > cs->transit_days[1]) { + transit_days -= cs->transit_days[1]; if (f < transit_days) { f = 0; @@ -1119,10 +1130,10 @@ Industry* ind; uint u; - // Check if there's an industry close to the station that accepts the cargo - // XXX - Think of something better to - // 1) Only deliver to industries which are withing the catchment radius - // 2) Distribute between industries if more then one is present + /* Check if there's an industry close to the station that accepts the cargo + * XXX - Think of something better to + * 1) Only deliver to industries which are withing the catchment radius + * 2) Distribute between industries if more then one is present */ u = (_patches.station_spread + 8) * 2; FOR_ALL_INDUSTRIES(ind) { uint t; @@ -1153,7 +1164,7 @@ Pair pair; Player *p; - // check if there is an already existing subsidy that applies to us + /* check if there is an already existing subsidy that applies to us */ for (s = _subsidies; s != endof(_subsidies); s++) { if (s->cargo_type == cargo_type && s->age >= 12 && @@ -1222,31 +1233,31 @@ assert(num_pieces > 0); - // Update player statistics + /* Update player statistics */ { Player *p = GetPlayer(_current_player); p->cur_economy.delivered_cargo += num_pieces; SETBIT(p->cargo_types, cargo_type); } - // Get station pointers. + /* Get station pointers. */ s_from = GetStation(source); s_to = GetStation(dest); - // Check if a subsidy applies. + /* Check if a subsidy applies. */ subsidised = CheckSubsidised(s_from, s_to, cargo_type); - // Increase town's counter for some special goods types + /* Increase town's counter for some special goods types */ if (cargo_type == CT_FOOD) s_to->town->new_act_food += num_pieces; if (cargo_type == CT_WATER) s_to->town->new_act_water += num_pieces; - // Give the goods to the industry. + /* Give the goods to the industry. */ DeliverGoodsToIndustry(s_to->xy, cargo_type, num_pieces); - // Determine profit + /* Determine profit */ profit = GetTransportedGoodsIncome(num_pieces, DistanceManhattan(source_tile, s_to->xy), days_in_transit, cargo_type); - // Modify profit if a subsidy is in effect + /* Modify profit if a subsidy is in effect */ if (subsidised) { switch (_opt.diff.subsidy_multiplier) { case 0: profit += profit >> 1; break; @@ -1372,10 +1383,10 @@ CLRBIT(u->load_status, LS_LOADING_FINISHED); if (v->cargo_source != last_visited && ge->waiting_acceptance & 0x8000 && !(u->current_order.flags & OF_TRANSFER)) { - // deliver goods to the station + /* deliver goods to the station */ st->time_since_unload = 0; - unloading_time += v->cargo_count; /* TTDBUG: bug in original TTD */ + unloading_time += v->cargo_count; // TTDBUG: bug in original TTD if (just_arrived && v->cargo_paid_for < v->cargo_count) { profit += DeliverGoods(v->cargo_count - v->cargo_paid_for, v->cargo_type, v->cargo_source, last_visited, v->cargo_source_xy, v->cargo_days); v->cargo_paid_for = v->cargo_count; @@ -1401,12 +1412,12 @@ unloading_time += v->cargo_count; t = GB(ge->waiting_acceptance, 0, 12); if (t == 0) { - // No goods waiting at station + /* No goods waiting at station */ ge->enroute_time = v->cargo_days; ge->enroute_from = v->cargo_source; ge->enroute_from_xy = v->cargo_source_xy; } else { - // Goods already waiting at station. Set counters to the worst value. + /* Goods already waiting at station. Set counters to the worst value. */ if (v->cargo_days >= ge->enroute_time) ge->enroute_time = v->cargo_days; if (last_visited != ge->enroute_from) { @@ -1414,7 +1425,7 @@ ge->enroute_from_xy = v->cargo_source_xy; } } - // Update amount of waiting cargo + /* Update amount of waiting cargo */ SB(ge->waiting_acceptance, 0, 12, min(amount_unloaded + t, 0xFFF)); if (u->current_order.flags & OF_TRANSFER) { @@ -1448,12 +1459,12 @@ default: t = u->max_speed; break; } - // if last speed is 0, we treat that as if no vehicle has ever visited the station. + /* if last speed is 0, we treat that as if no vehicle has ever visited the station. */ ge->last_speed = min(t, 255); ge->last_age = _cur_year - v->build_year; - // If there's goods waiting at the station, and the vehicle - // has capacity for it, load it on the vehicle. + /* If there's goods waiting at the station, and the vehicle + * has capacity for it, load it on the vehicle. */ if (count != 0 && (cap = v->cargo_cap - v->cargo_count) != 0) { int cargoshare; @@ -1470,7 +1481,7 @@ * loading them. Since this will cause * VEHICLE_TRIGGER_EMPTY to be called at the time when * the whole vehicle chain is really totally empty, the - * @completely_empty assignment can then be safely + * completely_empty assignment can then be safely * removed; that's how TTDPatch behaves too. --pasky */ completely_empty = false; anything_loaded = true; @@ -1487,7 +1498,7 @@ unloading_time += cap; st->time_since_load = 0; - // And record the source of the cargo, and the days in travel. + /* And record the source of the cargo, and the days in travel. */ v->cargo_source = ge->enroute_from; v->cargo_source_xy = ge->enroute_from_xy; v->cargo_days = ge->enroute_time; @@ -1518,7 +1529,7 @@ } if (v->type == VEH_Train) { - // Each platform tile is worth 2 rail vehicles. + /* Each platform tile is worth 2 rail vehicles. */ int overhang = v->u.rail.cached_total_length - st->GetPlatformLength(v->tile) * TILE_SIZE; if (overhang > 0) { unloading_time <<= 1; @@ -1560,7 +1571,7 @@ if (_patches.inflation && _cur_year < MAX_YEAR) AddInflation(); PlayersPayInterest(); - // Reset the _current_player flag + /* Reset the _current_player flag */ _current_player = OWNER_NONE; HandleEconomyFluctuations(); SubsidyMonthlyHandler(); @@ -1577,7 +1588,7 @@ SetDParam(2, p->bankrupt_value); AddNewsItem( (StringID)(_current_player | NB_BMERGER), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0); - // original code does this a little bit differently + /* original code does this a little bit differently */ PlayerID pi = p->index; ChangeOwnershipOfPlayerItems(pi, _current_player); @@ -1674,7 +1685,7 @@ if (flags & DC_EXEC) { PlayerByte* b = p->share_owners; - while (*b != _current_player) b++; /* share owners is guaranteed to contain player */ + while (*b != _current_player) b++; // share owners is guaranteed to contain player *b = PLAYER_SPECTATOR; InvalidateWindow(WC_COMPANY, p1); } @@ -1707,14 +1718,14 @@ return p->bankrupt_value; } -// Prices +/** Prices */ static void SaveLoad_PRIC(void) { SlArray(&_price, NUM_PRICES, SLE_INT32); SlArray(&_price_frac, NUM_PRICES, SLE_UINT16); } -// Cargo payment rates +/** Cargo payment rates */ static void SaveLoad_CAPR(void) { SlArray(&_cargo_payment_rates, NUM_CARGO, SLE_INT32); @@ -1731,7 +1742,7 @@ SLE_END() }; -// Economy variables +/** Economy variables */ static void SaveLoad_ECMY(void) { SlObject(&_economy, _economy_desc); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/economy.h --- a/src/economy.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/economy.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file economy.h */ + #ifndef ECONOMY_H #define ECONOMY_H @@ -7,15 +9,12 @@ void SetPriceBaseMultiplier(uint price, byte factor); typedef struct { - // Maximum possible loan - int32 max_loan; - int32 max_loan_unround; - // Economy fluctuation status + int32 max_loan; ///< Maximum possible loan + int32 max_loan_unround; ///< Economy fluctuation status int fluct; - // Interest - byte interest_rate; - byte infl_amount; - byte infl_amount_pr; + byte interest_rate; ///< Interest + byte infl_amount; ///< inflation amount + byte infl_amount_pr; ///< "floating" portion of inflation } Economy; VARDEF Economy _economy; @@ -40,19 +39,19 @@ SCORE_CARGO = 6, SCORE_MONEY = 7, SCORE_LOAN = 8, - SCORE_TOTAL = 9, // This must always be the last entry - SCORE_END = 10, // How many scores are there.. + SCORE_TOTAL = 9, ///< This must always be the last entry + SCORE_END = 10, ///< How many scores are there.. - SCORE_MAX = 1000 // The max score that can be in the performance history - // the scores together of score_info is allowed to be more! + SCORE_MAX = 1000 ///< The max score that can be in the performance history + /* the scores together of score_info is allowed to be more! */ }; DECLARE_POSTFIX_INCREMENT(ScoreID); typedef struct ScoreInfo { - byte id; // Unique ID of the score - int needed; // How much you need to get the perfect score - int score; // How much score it will give + byte id; ///< Unique ID of the score + int needed; ///< How much you need to get the perfect score + int score; ///< How much score it will give } ScoreInfo; extern const ScoreInfo _score_info[]; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/elrail.cpp --- a/src/elrail.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/elrail.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,5 @@ /* $Id$ */ -/** @file elrail.c +/** @file elrail.cpp * This file deals with displaying wires and pylons for electric railways. *

      Basics

      * diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/endian_check.cpp --- a/src/endian_check.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/endian_check.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,16 +1,17 @@ /* $Id$ */ +/** @file endian_check.cpp + * This pretty simple file checks if the system is LITTLE_ENDIAN or BIG_ENDIAN + * it does that by putting a 1 and a 0 in an array, and read it out as one + * number. If it is 1, it is LITTLE_ENDIAN, if it is 256, it is BIG_ENDIAN + * + * After that it outputs the contents of an include files (endian.h) + * that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes + * care of the real writing to the file. */ + #include #include -// This pretty simple file checks if the system is LITTLE_ENDIAN or BIG_ENDIAN -// it does that by putting a 1 and a 0 in an array, and read it out as one -// number. If it is 1, it is LITTLE_ENDIAN, if it is 256, it is BIG_ENDIAN -// -// After that it outputs the contents of an include files (endian.h) -// that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes -// care of the real writing to the file. - int main (int argc, char *argv[]) { unsigned char EndianTest[2] = { 1, 0 }; int force_BE = 0, force_LE = 0, force_PREPROCESSOR = 0; @@ -31,9 +32,9 @@ printf("#define TTD_BIG_ENDIAN\n"); } else { if (force_PREPROCESSOR == 1) { - // adding support for universal binaries on OSX - // Universal binaries supports both PPC and x86 - // If a compiler for OSX gets this setting, it will always pick the correct endian and no test is needed + /** adding support for universal binaries on OSX + * Universal binaries supports both PPC and x86 + * If a compiler for OSX gets this setting, it will always pick the correct endian and no test is needed */ printf("#ifdef __BIG_ENDIAN__\n"); printf("#define TTD_BIG_ENDIAN\n"); printf("#else\n"); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/engine.cpp --- a/src/engine.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/engine.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file engine.cpp */ + #include "stdafx.h" #include "openttd.h" #include "debug.h" @@ -122,9 +124,9 @@ e->flags = 0; e->player_avail = 0; - // The magic value of 729 days below comes from the NewGRF spec. If the - // base intro date is before 1922 then the random number of days is not - // added. + /* The magic value of 729 days below comes from the NewGRF spec. If the + * base intro date is before 1922 then the random number of days is not + * added. */ r = Random(); e->intro_date = ei->base_intro <= ConvertYMDToDate(1922, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro; if (e->intro_date <= _date) { @@ -154,7 +156,7 @@ e->lifelength = ei->lifelength + _patches.extend_vehicle_life; - // prevent certain engines from ever appearing. + /* prevent certain engines from ever appearing. */ if (!HASBIT(ei->climates, _opt.landscape)) { e->flags |= ENGINE_AVAILABLE; e->player_avail = 0; @@ -269,7 +271,7 @@ return 0; } -// Determine if an engine type is a wagon (and not a loco) +/* Determine if an engine type is a wagon (and not a loco) */ static bool IsWagon(EngineID index) { return index < NUM_TRAIN_ENGINES && RailVehInfo(index)->railveh_type == RAILVEH_WAGON; @@ -281,8 +283,8 @@ Player *p; EngineID index = e - _engines; - // In case the player didn't build the vehicle during the intro period, - // prevent that player from getting future intro periods for a while. + /* In case the player didn't build the vehicle during the intro period, + * prevent that player from getting future intro periods for a while. */ if (e->flags & ENGINE_INTRODUCING) { FOR_ALL_PLAYERS(p) { uint block_preview = p->block_preview; @@ -308,14 +310,14 @@ e->flags = (e->flags & ~ENGINE_INTRODUCING) | ENGINE_AVAILABLE; AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type); - // Now available for all players + /* Now available for all players */ e->player_avail = (byte)-1; - // Do not introduce new rail wagons + /* Do not introduce new rail wagons */ if (IsWagon(index)) return; if (index < NUM_TRAIN_ENGINES) { - // maybe make another rail type available + /* maybe make another rail type available */ RailType railtype = RailVehInfo(index)->railtype; assert(railtype < RAILTYPE_END); FOR_ALL_PLAYERS(p) { @@ -338,20 +340,20 @@ if (_cur_year < YEAR_ENGINE_AGING_STOPS) { for (e = _engines; e != endof(_engines); e++) { - // Age the vehicle + /* Age the vehicle */ if (e->flags & ENGINE_AVAILABLE && e->age != 0xFFFF) { e->age++; CalcEngineReliability(e); } if (!(e->flags & ENGINE_AVAILABLE) && _date >= (e->intro_date + 365)) { - // Introduce it to all players + /* Introduce it to all players */ NewVehicleAvailable(e); } else if (!(e->flags & (ENGINE_AVAILABLE|ENGINE_INTRODUCING)) && _date >= e->intro_date) { - // Introduction date has passed.. show introducing dialog to one player. + /* Introduction date has passed.. show introducing dialog to one player. */ e->flags |= ENGINE_INTRODUCING; - // Do not introduce new rail wagons + /* Do not introduce new rail wagons */ if (!IsWagon(e - _engines)) e->preview_player = (PlayerID)1; // Give to the player with the highest rating. } @@ -399,15 +401,15 @@ { const Engine *e; - // check if it's an engine that is in the engine array + /* check if it's an engine that is in the engine array */ if (!IsEngineIndex(engine)) return false; e = GetEngine(engine); - // check if it's an engine of specified type + /* check if it's an engine of specified type */ if (e->type != type) return false; - // check if it's available + /* check if it's available */ if (!HASBIT(e->player_avail, player)) return false; return true; @@ -595,7 +597,7 @@ SLE_CONDNULL(1, 0, 44), SLE_VAR(Engine, player_avail, SLE_UINT8), - // reserve extra space in savegame here. (currently 16 bytes) + /* reserve extra space in savegame here. (currently 16 bytes) */ SLE_CONDNULL(16, 2, SL_MAX_VERSION), SLE_END() diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/engine.h --- a/src/engine.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/engine.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,19 +1,19 @@ /* $Id$ */ +/** @file engine.h */ + #ifndef ENGINE_H #define ENGINE_H -/** @file engine.h */ - #include "oldpool.h" #include "rail.h" #include "sound.h" #include "vehicle.h" enum RailVehicleTypes { - RAILVEH_SINGLEHEAD, - RAILVEH_MULTIHEAD, - RAILVEH_WAGON, + RAILVEH_SINGLEHEAD, ///< indicates a "standalone" locomotive + RAILVEH_MULTIHEAD, ///< indicates a combination of two locomotives + RAILVEH_WAGON, ///< simple wagon, not motorized }; typedef struct RailVehicleInfo { @@ -26,7 +26,7 @@ uint16 weight; byte running_cost_base; byte running_cost_class; - byte engclass; // 0: steam, 1: diesel, 2: electric + byte engclass; ///< 0: steam, 1: diesel, 2: electric byte capacity; CargoID cargo_type; byte ai_rank; @@ -36,9 +36,9 @@ // for when the 'powered wagon' callback fails. But it should really also determine what // kind of visual effect to generate for a vehicle (default, steam, diesel, electric). // Same goes for the callback result, which atm is only used to check if a wagon is powered. - byte shorten_factor; // length on main map for this type is 8 - shorten_factor + byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor byte tractive_effort; ///< Tractive effort coefficient - byte user_def_data; ///! Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles + byte user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles } RailVehicleInfo; typedef struct ShipVehicleInfo { @@ -57,7 +57,7 @@ * in which case bit 1 tells us whether it's a big(fast) plane or not */ enum { AIR_HELI = 0, - AIR_CTOL = 1, // Conventional Take Off and Landing, i.e. planes + AIR_CTOL = 1, ///< Conventional Take Off and Landing, i.e. planes AIR_FAST = 2 }; @@ -111,7 +111,7 @@ PlayerByte preview_player; byte preview_wait; byte player_avail; - byte type; // type, ie VEH_Road, VEH_Train, etc. Same as in vehicle.h + byte type; ///< type, ie VEH_Road, VEH_Train, etc. Same as in vehicle.h } Engine; /** diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/engine_gui.cpp --- a/src/engine_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/engine_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file engine_gui.cpp */ + #include "stdafx.h" #include "openttd.h" #include "table/strings.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/fios.cpp --- a/src/fios.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/fios.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,6 +1,6 @@ /* $Id$ */ -/** @file fios.c +/** @file fios.cpp * This file contains functions for building file lists for the save/load dialogs. */ @@ -21,7 +21,6 @@ # include #else # include -# include #endif /* WIN32 */ /* Variables to display file lists */ @@ -187,9 +186,7 @@ { #if defined(WINCE) /* There is always one platform that doesn't support basic commands... */ - HANDLE hand; - - hand = CreateFile(OTTD2FS(filename), 0, 0, NULL, OPEN_EXISTING, 0, NULL); + HANDLE hand = CreateFile(OTTD2FS(filename), 0, 0, NULL, OPEN_EXISTING, 0, NULL); if (hand == INVALID_HANDLE_VALUE) return 1; CloseHandle(hand); return 0; @@ -212,6 +209,7 @@ DIR *dir; FiosItem *fios; int sort_start; + char d_name[sizeof(fios->name)]; /* A parent directory link exists if we are not in the root directory */ if (!FiosIsRoot(_fios_path) && mode != SLD_NEW_GAME) { @@ -223,9 +221,9 @@ } /* Show subdirectories */ - if (mode != SLD_NEW_GAME && (dir = opendir(_fios_path)) != NULL) { + if (mode != SLD_NEW_GAME && (dir = ttd_opendir(_fios_path)) != NULL) { while ((dirent = readdir(dir)) != NULL) { - const char *d_name = FS2OTTD(dirent->d_name); + ttd_strlcpy(d_name, FS2OTTD(dirent->d_name), sizeof(d_name)); /* found file must be directory, but not '.' or '..' */ if (FiosIsValidFile(_fios_path, dirent, &sb) && (sb.st_mode & S_IFDIR) && @@ -253,13 +251,12 @@ sort_start = _fios_count; /* Show files */ - dir = opendir(_fios_path); + dir = ttd_opendir(_fios_path); if (dir != NULL) { while ((dirent = readdir(dir)) != NULL) { char fios_title[64]; char *t; - char *d_name = (char*)FS2OTTD(dirent->d_name); - byte type; + ttd_strlcpy(d_name, FS2OTTD(dirent->d_name), sizeof(d_name)); if (!FiosIsValidFile(_fios_path, dirent, &sb) || !(sb.st_mode & S_IFREG)) continue; @@ -267,7 +264,7 @@ if ((t = strrchr(d_name, '.')) == NULL) continue; fios_title[0] = '\0'; // reset the title; - type = callback_proc(mode, d_name, t, fios_title); + byte type = callback_proc(mode, d_name, t, fios_title); if (type != FIOS_TYPE_INVALID) { fios = FiosAlloc(); fios->mtime = sb.st_mtime; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/fios.h --- a/src/fios.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/fios.h Wed Feb 28 00:33:40 2007 +0000 @@ -77,10 +77,25 @@ bool at_first_entry; }; -DIR *opendir(const char *path); +DIR *opendir(const wchar_t *path); struct dirent *readdir(DIR *d); int closedir(DIR *d); - +#else +/* Use system-supplied opendir/readdir/closedir functions */ +# include +# include #endif /* defined(WIN32) */ +/** + * A wrapper around opendir() which will convert the string from + * OPENTTD encoding to that of the filesystem. For all purposes this + * function behaves the same as the original opendir function + * @param path string to open directory of + * @return DIR pointer + */ +static inline DIR *ttd_opendir(const char *path) +{ + return opendir(OTTD2FS(path)); +} + #endif /* FIOS_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/gfx.cpp --- a/src/gfx.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/gfx.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1987,18 +1987,14 @@ static void SwitchAnimatedCursor(void) { - CursorVars *cv = &_cursor; - const CursorID *cur = cv->animate_cur; - CursorID sprite; + const AnimCursor *cur = _cursor.animate_cur; - // ANIM_CURSOR_END is 0xFFFF in table/animcursors.h - if (cur == NULL || *cur == 0xFFFF) cur = cv->animate_list; + if (cur == NULL || cur->sprite == AnimCursor::LAST) cur = _cursor.animate_list; - sprite = cur[0]; - cv->animate_timeout = cur[1]; - cv->animate_cur = cur + 2; + SetCursorSprite(cur->sprite, _cursor.pal); - SetCursorSprite(sprite, cv->pal); + _cursor.animate_timeout = cur->display_time; + _cursor.animate_cur = cur + 1; } void CursorTick(void) @@ -2015,7 +2011,7 @@ SetCursorSprite(sprite, pal); } -void SetAnimatedMouseCursor(const CursorID *table) +void SetAnimatedMouseCursor(const AnimCursor *table) { _cursor.animate_list = table; _cursor.animate_cur = NULL; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/gfx.h --- a/src/gfx.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/gfx.h Wed Feb 28 00:33:40 2007 +0000 @@ -96,6 +96,12 @@ int left,top,right,bottom; } Rect; +/** A single sprite of a list of animated cursors */ +struct AnimCursor { + static const CursorID LAST = MAX_UVALUE(CursorID); + CursorID sprite; ///< Must be set to LAST_ANIM when it is the last sprite of the loop + byte display_time; ///< Amount of ticks this sprite will be shown +}; typedef struct CursorVars { Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement @@ -104,8 +110,9 @@ SpriteID pal; int wheel; ///< mouse wheel movement - const CursorID *animate_list, *animate_cur; ///< in case of animated cursor, list of frames - uint animate_timeout; ///< current frame in list of animated cursor + const AnimCursor *animate_list; ///< in case of animated cursor, list of frames + const AnimCursor *animate_cur; ///< in case of animated cursor, current frame + uint animate_timeout; ///< in case of animated cursor, number of ticks to show the current cursor bool visible; ///< cursor is visible bool dirty; ///< the rect occupied by the mouse is dirty (redraw) @@ -226,7 +233,7 @@ void SetMouseCursor(CursorID cursor); void SetMouseCursor(SpriteID sprite, SpriteID pal); -void SetAnimatedMouseCursor(const CursorID *table); +void SetAnimatedMouseCursor(const AnimCursor *table); void CursorTick(void); void DrawMouseCursor(void); void ScreenSizeChanged(void); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/gfxinit.cpp --- a/src/gfxinit.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/gfxinit.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -333,6 +333,7 @@ 377, 377, // · small 153, 153, // · medium 601, 601, // · large + SPR_WARNING_SIGN, SPR_WARNING_SIGN, END }; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/graph_gui.cpp --- a/src/graph_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/graph_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -13,8 +13,7 @@ #include "variables.h" #include "date.h" #include "helpers.hpp" - -const byte _cargo_colours[NUM_CARGO] = {152, 32, 15, 174, 208, 194, 191, 84, 184, 10, 202, 48}; +#include "cargotype.h" /* Bitmasks of player and cargo indices that shouldn't be drawn. */ static uint _legend_excluded_players; @@ -749,13 +748,14 @@ * clk_dif will move one pixel down and one pixel to the right * when the button is clicked */ byte clk_dif = w->IsWidgetLowered(i + 3) ? 1 : 0; + const CargoSpec *cs = GetCargo(i); GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0); - GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, _cargo_colours[i]); - SetDParam(0, _cargoc.names_s[i]); + GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour); + SetDParam(0, cs->name != 0 ? cs->name : (StringID)STR_EMPTY); DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, 0); y += 8; - gd.colors[i] = _cargo_colours[i]; + gd.colors[i] = cs->legend_colour; for (j = 0; j != 20; j++) { gd.cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 6 + 6, i); } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/gui.h --- a/src/gui.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/gui.h Wed Feb 28 00:33:40 2007 +0000 @@ -20,7 +20,6 @@ void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right); /* graph_gui.c */ -extern const byte _cargo_colours[NUM_CARGO]; void ShowOperatingProfitGraph(void); void ShowIncomeGraph(void); void ShowDeliveredCargoGraph(void); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/helpers.hpp --- a/src/helpers.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/helpers.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -6,8 +6,6 @@ /** @file helpers.hpp */ #include "macros.h" -#ifdef __cplusplus - /** 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 FORCEINLINE T* MallocT(size_t num_elements) @@ -82,12 +80,23 @@ /** 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<>. */ + * we will create specialization derived from MakeEnumPropsT<>. + * i.e.: + * template <> struct EnumPropsT : MakeEnumPropsT {}; + * followed by: + * typedef TinyEnumT TrackByte; + */ template 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. */ + * 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 struct MakeEnumPropsT { typedef Tenum_t type; ///< enum type (i.e. Trackdir) @@ -140,25 +149,19 @@ } }; -template FORCEINLINE T ClrBitT(T t, int bit_index) +template void ClrBitT(T &t, int bit_index) { - int val = t; - CLRBIT(val, bit_index); - return (T)val; + t = (T)(t & ~((T)1 << bit_index)); } -template FORCEINLINE T SetBitT(T t, int bit_index) +template void SetBitT(T &t, int bit_index) { - int val = t; - SETBIT(val, bit_index); - return (T)val; + t = (T)(t | ((T)1 << bit_index)); } -template FORCEINLINE T ToggleBitT(T t, int bit_index) +template void ToggleBitT(T &t, int bit_index) { - int val = t; - TOGGLEBIT(val, bit_index); - return (T)val; + t = (T)(t ^ ((T)1 << bit_index)); } /** @@ -182,12 +185,4 @@ } }; -#else // __cplusplus - -#define DECLARE_POSTFIX_INCREMENT(E) -#define DECLARE_ENUM_AS_BIT_SET(E) -#define DECLARE_ENUM_AS_BIT_INDEX(E1,E2) - -#endif // __cplusplus - #endif /* HELPERS_HPP */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/industry.h --- a/src/industry.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/industry.h Wed Feb 28 00:33:40 2007 +0000 @@ -78,7 +78,13 @@ StringID production_down_text; } IndustrySpec; +typedef struct IndustryTileSpec { + CargoID accepts_cargo[3]; + Slope slopes_refused; +} IndustryTileSpec; + const IndustrySpec *GetIndustrySpec(IndustryType thistype); +const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx); DECLARE_OLD_POOL(Industry, Industry, 3, 8000) diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/industry_cmd.cpp --- a/src/industry_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/industry_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -26,6 +26,7 @@ #include "date.h" #include "water_map.h" #include "tree_map.h" +#include "cargotype.h" void ShowIndustryViewWindow(int industry); void BuildOilRig(TileIndex tile); @@ -86,6 +87,12 @@ return &_industry_specs[thistype]; } +const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx) +{ + assert(gfx < NUM_INDUSTRY_GFXES); + return &_industry_tile_specs[gfx]; +} + void DestroyIndustry(Industry *i) { BEGIN_TILE_LOOP(tile_cur, i->width, i->height, i->xy); @@ -276,16 +283,16 @@ static void GetAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac) { - IndustryGfx gfx = GetIndustryGfx(tile); + const IndustryTileSpec *itspec = GetIndustryTileSpec(GetIndustryGfx(tile)); CargoID a; - a = _industry_section_accepts_1[gfx]; - if (a != CT_INVALID) ac[a] = (a == 0) ? 1 : 8; + a = itspec->accepts_cargo[0]; + if (a != CT_INVALID) ac[a] = (a == CT_PASSENGERS) ? 1 : 8; - a = _industry_section_accepts_2[gfx]; + a = itspec->accepts_cargo[1]; if (a != CT_INVALID) ac[a] = 8; - a = _industry_section_accepts_3[gfx]; + a = itspec->accepts_cargo[2]; if (a != CT_INVALID) ac[a] = 8; } @@ -1154,7 +1161,7 @@ * CheckIfCanLevelIndustryPlatform(). */ if (tileh != SLOPE_FLAT) { Slope t; - byte bits = _industry_section_bits[it->gfx]; + byte bits = GetIndustryTileSpec(it->gfx)->slopes_refused; if (bits & 0x10) return false; @@ -1624,7 +1631,7 @@ mag = abs(percent); if (mag >= 10) { SetDParam(2, mag); - SetDParam(0, _cargoc.names_s[i->produced_cargo[j]]); + SetDParam(0, GetCargo(i->produced_cargo[j])->name); SetDParam(1, i->index); AddNewsItem( percent >= 0 ? STR_INDUSTRY_PROD_GOUP : STR_INDUSTRY_PROD_GODOWN, diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/industry_gui.cpp --- a/src/industry_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/industry_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -17,6 +17,7 @@ #include "town.h" #include "variables.h" #include "helpers.hpp" +#include "cargotype.h" const byte _build_industry_types[4][12] = { { 1, 2, 4, 6, 8, 0, 3, 5, 9, 11, 18 }, @@ -303,13 +304,13 @@ if (i->accepts_cargo[0] != CT_INVALID) { StringID str; - SetDParam(0, _cargoc.names_s[i->accepts_cargo[0]]); + SetDParam(0, GetCargo(i->accepts_cargo[0])->name); str = STR_4827_REQUIRES; if (i->accepts_cargo[1] != CT_INVALID) { - SetDParam(1, _cargoc.names_s[i->accepts_cargo[1]]); + SetDParam(1, GetCargo(i->accepts_cargo[1])->name); str = STR_4828_REQUIRES; if (i->accepts_cargo[2] != CT_INVALID) { - SetDParam(2, _cargoc.names_s[i->accepts_cargo[2]]); + SetDParam(2, GetCargo(i->accepts_cargo[2])->name); str = STR_4829_REQUIRES; } } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/landscape.cpp --- a/src/landscape.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/landscape.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -337,8 +337,8 @@ ey = TileY(tile); sx = TileX(p1); sy = TileY(p1); - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); money = GetAvailableMoneyForCommand(); cost = 0; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/brazilian_portuguese.txt --- a/src/lang/brazilian_portuguese.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/brazilian_portuguese.txt Wed Feb 28 00:33:40 2007 +0000 @@ -36,7 +36,7 @@ STR_001B_MAIZE :{G=m}Milho STR_001C_FRUIT :{G=f}Fruta STR_001D_DIAMONDS :{G=m}Diamante -STR_001E_FOOD :{G=m}Alimento +STR_001E_FOOD :{G=f}Comida STR_001F_PAPER :{G=m}Papel STR_0020_GOLD :{G=m}Ouro STR_0021_WATER :{G=f}Ãgua @@ -53,37 +53,37 @@ STR_002C_PLASTIC :{G=m}Plástico STR_002D_FIZZY_DRINKS :{G=m}Refrigerantes STR_002E : -STR_002F_PASSENGER :{G=m}passageiros -STR_0030_COAL :{G=m}carvão -STR_0031_MAIL :{G=f}cartas -STR_0032_OIL :{G=m}petróleo -STR_0033_LIVESTOCK :{G=m}gado -STR_0034_GOODS :{G=m}bens -STR_0035_GRAIN :{G=m}grãos -STR_0036_WOOD :{G=f}madeira -STR_0037_IRON_ORE :{G=m}minério de ferro -STR_0038_STEEL :{G=m}aço -STR_0039_VALUABLES :{G=m}dinheiro -STR_003A_COPPER_ORE :{G=m}minério de cobre -STR_003B_MAIZE :{G=m}milho -STR_003C_FRUIT :{G=f}fruta -STR_003D_DIAMOND :{G=m}diamante -STR_003E_FOOD :{G=m}alimento -STR_003F_PAPER :{G=m}papel -STR_0040_GOLD :{G=m}ouro -STR_0041_WATER :{G=f}água -STR_0042_WHEAT :{G=m}trigo -STR_0043_RUBBER :{G=f}borracha -STR_0044_SUGAR :{G=m}açúcar -STR_0045_TOY :{G=m}brinquedos -STR_0046_CANDY :{G=m}doces -STR_0047_COLA :{G=f}cola -STR_0048_COTTON_CANDY :{G=m}algodão doce -STR_0049_BUBBLE :{G=f}bolhas -STR_004A_TOFFEE :{G=m}caramelo -STR_004B_BATTERY :{G=f}pilhas -STR_004C_PLASTIC :{G=m}plástico -STR_004D_FIZZY_DRINK :{G=m}refrigerantes +STR_002F_PASSENGER :{G=m}Passageiros +STR_0030_COAL :{G=m}Carvão +STR_0031_MAIL :{G=f}Cartas +STR_0032_OIL :{G=m}Petróleo +STR_0033_LIVESTOCK :{G=m}Gado +STR_0034_GOODS :{G=m}Bens +STR_0035_GRAIN :{G=m}Grãos +STR_0036_WOOD :{G=f}Madeira +STR_0037_IRON_ORE :{G=m}Minério de ferro +STR_0038_STEEL :{G=m}Aço +STR_0039_VALUABLES :{G=m}Dinheiro +STR_003A_COPPER_ORE :{G=m}Minério de cobre +STR_003B_MAIZE :{G=m}Milho +STR_003C_FRUIT :{G=f}Fruta +STR_003D_DIAMOND :{G=m}Diamante +STR_003E_FOOD :{G=f}Comida +STR_003F_PAPER :{G=m}Papel +STR_0040_GOLD :{G=m}Ouro +STR_0041_WATER :{G=f}Ãgua +STR_0042_WHEAT :{G=m}Trigo +STR_0043_RUBBER :{G=f}Borracha +STR_0044_SUGAR :{G=m}Açúcar +STR_0045_TOY :{G=m}Brinquedos +STR_0046_CANDY :{G=m}Doces +STR_0047_COLA :{G=f}Cola +STR_0048_COTTON_CANDY :{G=m}Algodão doce +STR_0049_BUBBLE :{G=f}Bolhas +STR_004A_TOFFEE :{G=m}Caramelo +STR_004B_BATTERY :{G=f}Pilhas +STR_004C_PLASTIC :{G=m}Plástico +STR_004D_FIZZY_DRINK :{G=m}Refrigerantes STR_QUANTITY_NOTHING : STR_QUANTITY_PASSENGERS :{COMMA} passageiro{P "" s} STR_QUANTITY_COAL :{WEIGHT} de carvão @@ -186,7 +186,7 @@ STR_00D8_DARK_GREEN :Verde Escuro STR_00D9_BLUE :Azul STR_00DA_CREAM :Creme -STR_00DB_MAUVE :Preto +STR_00DB_MAUVE :Malva STR_00DC_PURPLE :Roxo STR_00DD_ORANGE :Laranja STR_00DE_BROWN :Marrom @@ -214,7 +214,7 @@ STR_00F4_500M :{BLACK}{TINYFONT}500m STR_00F5_TRAINS :{BLACK}{TINYFONT}Trens STR_00F6_ROAD_VEHICLES :{BLACK}{TINYFONT}Automóveis -STR_00F7_SHIPS :{BLACK}{TINYFONT}Embarcações +STR_00F7_SHIPS :{BLACK}{TINYFONT}Navios STR_00F8_AIRCRAFT :{BLACK}{TINYFONT}Aeronaves STR_00F9_TRANSPORT_ROUTES :{BLACK}{TINYFONT}Rotas de Transporte STR_00FA_COAL_MINE :{BLACK}{TINYFONT}Mina de Carvão @@ -234,10 +234,10 @@ STR_0108_FOOD_PROCESSING_PLANT :{BLACK}{TINYFONT}Indústria Alimentícia STR_0109_DIAMOND_MINE :{BLACK}{TINYFONT}Mina de Diamante STR_010A_COPPER_ORE_MINE :{BLACK}{TINYFONT}Mina de Cobre -STR_010B_FRUIT_PLANTATION :{BLACK}{TINYFONT}Pomar +STR_010B_FRUIT_PLANTATION :{BLACK}{TINYFONT}Plantação de Frutas STR_010C_RUBBER_PLANTATION :{BLACK}{TINYFONT}Plantação de Seringueiras -STR_010D_WATER_SUPPLY :{BLACK}{TINYFONT}Poço Artesiano -STR_010E_WATER_TOWER :{BLACK}{TINYFONT}Reservatório de Ãgua +STR_010D_WATER_SUPPLY :{BLACK}{TINYFONT}Poço de Ãgua +STR_010E_WATER_TOWER :{BLACK}{TINYFONT}Reservatório STR_010F_LUMBER_MILL :{BLACK}{TINYFONT}Serraria STR_0110_COTTON_CANDY_FOREST :{BLACK}{TINYFONT}Floresta de Algodão Doce STR_0111_CANDY_FACTORY :{BLACK}{TINYFONT}Fábrica de Doces @@ -316,7 +316,7 @@ STR_UNITS_IMPERIAL :Imperial STR_UNITS_METRIC :Métrico -STR_UNITS_SI :SI +STR_UNITS_SI :Sistema Internacional STR_UNITS_VELOCITY_IMPERIAL :{COMMA} mph STR_UNITS_VELOCITY_METRIC :{COMMA} km/h @@ -1043,7 +1043,7 @@ STR_CONFIG_PATCHES_NONUNIFORM_STATIONS :{LTBLUE}Estações não uniformes: {ORANGE}{STRING} STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL :{LTBLUE}Novo busca de caminho global (NPF, sobrepõe NTP): {ORANGE}{STRING} STR_CONFIG_PATCHES_FREIGHT_TRAINS :{LTBLUE}Multiplicador de peso para trens simulando trens pesados: {ORANGE}{STRING} -STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD :{LTBLUE}Permite dirigir em pontos de parada nas estradas particulares de cidade: {ORANGE}{STRING} +STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD :{LTBLUE}Permitir estações drive-through em ruas locais: {ORANGE}{STRING} STR_CONFIG_PATCHES_SMALL_AIRPORTS :{LTBLUE}Permitir sempre aeroportos pequenos: {ORANGE}{STRING} @@ -1160,7 +1160,7 @@ STR_CHEAT_EXTRA_DYNAMITE :{LTBLUE}Bulldozer mágico (destrói indústrias, etc.): {ORANGE}{STRING} STR_CHEAT_CROSSINGTUNNELS :{LTBLUE}Os túneis poderão cruzar-se: {ORANGE}{STRING} STR_CHEAT_BUILD_IN_PAUSE :{LTBLUE}Permitir construção quando em pausa: {ORANGE}{STRING} -STR_CHEAT_NO_JETCRASH :{LTBLUE}Aeronaves a jato não irão acidentar (frequentemente) em aeroportos pequenos: {ORANGE} {STRING} +STR_CHEAT_NO_JETCRASH :{LTBLUE}Aeronaves a jato não irão se acidentar (frequentemente) em aeroportos pequenos: {ORANGE} {STRING} STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Mudar de clima: {ORANGE} {STRING} STR_CHEAT_CHANGE_DATE :{LTBLUE}Alterar data: {ORANGE} {DATE_SHORT} STR_CHEAT_SETUP_PROD :{LTBLUE}Ativar modificação de valores de produção: {ORANGE}{STRING} @@ -1272,7 +1272,7 @@ STR_CONFIG_GAME_PRODUCTION :{WHITE}Modificar produção TEMP_AI_IN_PROGRESS :{WHITE}Bem-vindo à nova IA, ainda em desenvolvimento. Se você encontrar problemas tire um printscreen e poste no fórum. -TEMP_AI_ACTIVATED :{WHITE}Atenção: esta nova IA está ainda em versão alpha! Atualmente, só funcionam caminhões e ônibus! +TEMP_AI_ACTIVATED :{WHITE}Atenção: esta nova IA está ainda em versão alfa! Atualmente, só funcionam caminhões e ônibus! TEMP_AI_MULTIPLAYER :{WHITE}Atenção: esta função ainda é experimental (usando a nova IA). Por favor reporte quaisquer problemas para truelight@openttd.org. ############ network gui strings @@ -1530,7 +1530,7 @@ STR_100A_RAILROAD_CONSTRUCTION :{WHITE}Construir ferrovias STR_TITLE_ELRAIL_CONSTRUCTION :{WHITE}Construir ferrovias (elétricas) STR_100B_MONORAIL_CONSTRUCTION :{WHITE}Construir ferrovias (monotrilho) -STR_100C_MAGLEV_CONSTRUCTION :{WHITE}Construir ferrovias (trem-bala) +STR_100C_MAGLEV_CONSTRUCTION :{WHITE}Construir ferrovias MagLev STR_100D_SELECT_RAIL_BRIDGE :{WHITE}Selecionar Ponte Ferroviária STR_100E_CAN_T_BUILD_TRAIN_DEPOT :{WHITE}Impossível construir depósito aqui... STR_100F_CAN_T_BUILD_RAILROAD_STATION :{WHITE}Impossível construir estação ferroviária aqui... @@ -1542,7 +1542,7 @@ STR_1015_RAILROAD_CONSTRUCTION :Construir ferrovias STR_TOOLB_ELRAIL_CONSTRUCTION :Construir ferrovias (elétricas) STR_1016_MONORAIL_CONSTRUCTION :Construir ferrovias (monotrilho) -STR_1017_MAGLEV_CONSTRUCTION :Construir ferrovias (trem-bala) +STR_1017_MAGLEV_CONSTRUCTION :Construir ferrovias MagLev STR_1018_BUILD_RAILROAD_TRACK :{BLACK}Construir ferrovias STR_1019_BUILD_TRAIN_DEPOT_FOR_BUILDING :{BLACK}Construir depósito (para construção e manutenção de trens) STR_101A_BUILD_RAILROAD_STATION :{BLACK}Construir estação ferroviária @@ -1572,7 +1572,7 @@ STR_1806_ROAD_DEPOT_ORIENTATION :{WHITE}Orientação da Garagem STR_1807_CAN_T_BUILD_ROAD_VEHICLE :{WHITE}Impossível construir garagem aqui... STR_1808_CAN_T_BUILD_BUS_STATION :{WHITE}Impossível construir estação de ônibus... -STR_1809_CAN_T_BUILD_TRUCK_STATION :{WHITE}Impossível construir parada de caminhão +STR_1809_CAN_T_BUILD_TRUCK_STATION :{WHITE}Impossível construir estação de caminhão STR_180A_ROAD_CONSTRUCTION :Construir rodovias STR_180B_BUILD_ROAD_SECTION :{BLACK}Construir trecho rodoviário STR_180C_BUILD_ROAD_VEHICLE_DEPOT :{BLACK}Construir garagem (para construção e manutenção de automóveis) @@ -1723,7 +1723,7 @@ STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING :{WHITE}Muito perto de uma estação/local de carga já existente STR_3007_TOO_MANY_STATIONS_LOADING :{WHITE}Muitas estações/áreas de carga nesta cidade STR_3008_TOO_MANY_STATIONS_LOADING :{WHITE}Muitas estações/áreas de carga -STR_3008A_TOO_MANY_BUS_STOPS :{WHITE}Muitos pontos de ônibus +STR_3008A_TOO_MANY_BUS_STOPS :{WHITE}Muitas estações de ônibus STR_3008B_TOO_MANY_TRUCK_STOPS :{WHITE}Muitos locais de carga STR_3009_TOO_CLOSE_TO_ANOTHER_STATION :{WHITE}Muito perto de outra estação/local de carga STR_300A_0 :{WHITE}{STATION} {STATIONFEATURES} @@ -1754,9 +1754,9 @@ STR_3040_NOW_ACCEPTS :{WHITE}{STATION} agora aceita {STRING} STR_3041_NOW_ACCEPTS_AND :{WHITE}{STATION} agora aceita {STRING} e {STRING} STR_3042_BUS_STATION_ORIENTATION :{WHITE}Orientação do estação de ônibus -STR_3043_TRUCK_STATION_ORIENT :{WHITE}Orientação da parada de caminhão +STR_3043_TRUCK_STATION_ORIENT :{WHITE}Orientação da estação de caminhão STR_3046_MUST_DEMOLISH_BUS_STATION :{WHITE}Precisa demolir a estação de ônibus primeiro -STR_3047_MUST_DEMOLISH_TRUCK_STATION :{WHITE}Precisa demolir a parada de caminhão primeiro +STR_3047_MUST_DEMOLISH_TRUCK_STATION :{WHITE}Precisa demolir a estação de caminhão STR_3048_STATIONS :{WHITE}{COMPANY} - {COMMA} Estações STR_3049_0 :{YELLOW}{STATION} {STATIONFEATURES} STR_304A_NONE :{YELLOW}- Nenhuma - @@ -1892,7 +1892,7 @@ STR_483A_INSECT_INFESTATION_CAUSES :{BLACK}{BIGFONT}Infestação de insetos causa destruição em {INDUSTRY}!{}Produção diminui em 50% STR_483B_CAN_ONLY_BE_POSITIONED :{WHITE}...só pode ser colocado perto das bordas do mapa STR_INDUSTRY_PROD_GOUP :{BLACK}{BIGFONT}A produção de {STRING} em {INDUSTRY} aumentou em {COMMA}%! -STR_INDUSTRY_PROD_GODOWN :{BLACK}{BIGFONT}A produção de {STRING} em {INDUSTRY} diminuiu em {COMMA}%! +STR_INDUSTRY_PROD_GODOWN :{BLACK}{BIGFONT}A produção de {STRING} na {INDUSTRY} diminuiu em {COMMA}%! ##id 0x5000 STR_5000_TRAIN_IN_TUNNEL :{WHITE}Há um trem no túnel @@ -2884,7 +2884,7 @@ STR_PERFORMANCE_DETAIL_TOTAL :{BLACK}Total: ############ End of order list STR_PERFORMANCE_DETAIL_VEHICLES_TIP :{BLACK}Número de veículos: Incluindo automóveis, trens, embarcações e aeronaves. -STR_PERFORMANCE_DETAIL_STATIONS_TIP :{BLACK}Número de segmentos de estação. Cada parte de uma estação (ex. estação ferroviária, ponto de ônibus, aeroporto) é contado, mesmo se eles estiverem ligados a uma estação. +STR_PERFORMANCE_DETAIL_STATIONS_TIP :{BLACK}Número de segmentos de estação. Cada parte de uma estação (ex. estação ferroviária, estação de ônibus, aeroporto) é contado, mesmo se eles estiverem ligados a uma estação. STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP :{BLACK}O lucro do veículo com o rendimento menor (de todos os veículos com mais de 2 anos) STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP :{BLACK}Dinheiro conseguido no mês com os lucros mais baixos dos últimos 12 trimestres STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP :{BLACK}Dinheiro conseguido no mês com os lucros mais altos dos últimos 12 trimestres diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/bulgarian.txt --- a/src/lang/bulgarian.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/bulgarian.txt Wed Feb 28 00:33:40 2007 +0000 @@ -1828,7 +1828,7 @@ STR_4800_IN_THE_WAY :{WHITE}{STRING} пречи STR_4801 :{WHITE}{INDUSTRY} STR_4802_COAL_MINE :Мина за въглища -STR_4803_POWER_STATION : +STR_4803_POWER_STATION :Електроцентрала STR_4804_SAWMILL :ДъÑкорезница STR_4805_FOREST :Гора STR_4806_OIL_REFINERY :Ðефтена Ñ€Ð°Ñ„Ð¸Ð½ÐµÑ€Ð¸Ñ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/catalan.txt --- a/src/lang/catalan.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/catalan.txt Wed Feb 28 00:33:40 2007 +0000 @@ -1235,7 +1235,7 @@ STR_MESSAGES_ENABLE_ALL :{BLACK}Activa tots STR_CONSTRUCT_COAL_MINE_TIP :{BLACK}Construeix Mina de Carbó -STR_CONSTRUCT_FOREST_TIP :{BLACK}Planta Bosc +STR_CONSTRUCT_FOREST_TIP :{BLACK}Planta un Bosc STR_CONSTRUCT_OIL_RIG_TIP :{BLACK}Construeix una Plataforma Petrolífera STR_CONSTRUCT_FARM_TIP :{BLACK}Funda Granja STR_CONSTRUCT_COPPER_ORE_MINE_TIP :{BLACK}Construeix una Mina de Coure @@ -1246,7 +1246,7 @@ STR_CONSTRUCT_FRUIT_PLANTATION_TIP :{BLACK}Funda Plantació de Fruita STR_CONSTRUCT_RUBBER_PLANTATION_TIP :{BLACK}Funda Plantació de Cautxú STR_CONSTRUCT_WATER_SUPPLY_TIP :{BLACK}Funda Surtidor d'Aigua -STR_CONSTRUCT_COTTON_CANDY_TIP :{BLACK}Planta Bosc de Cotó de Sucre +STR_CONSTRUCT_COTTON_CANDY_TIP :{BLACK}Planta un Bosc de Cotó de Sucre STR_CONSTRUCT_BATTERY_FARM_TIP :{BLACK}Funda Granja de Piles STR_CONSTRUCT_COLA_WELLS_TIP :{BLACK}Perfora per buscar Cola STR_CONSTRUCT_PLASTIC_FOUNTAINS_TIP :{BLACK}Funda Fonts de Plàstic diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/czech.txt --- a/src/lang/czech.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/czech.txt Wed Feb 28 00:33:40 2007 +0000 @@ -2540,13 +2540,16 @@ STR_8101_WE_HAVE_JUST_DESIGNED_A :{GOLD}PrávÄ› jsme vyvinuli nov{G ý ou é} {STRING.acc}. MÄ›l byste zájem o roÄní výhradní právo na používání tohoto prostÅ™edku, aby byl otestován pÅ™ed uvedením na trh? STR_8102_RAILROAD_LOCOMOTIVE :{G=f}lokomotiva STR_8102_RAILROAD_LOCOMOTIVE.acc :{G=f}lokomotivu +STR_8102_RAILROAD_LOCOMOTIVE.dat :{G=f}lokomotivu STR_8103_ROAD_VEHICLE :{G=n}silniÄní vozidlo STR_8104_AIRCRAFT :{G=n}letadlo STR_8105_SHIP :{G=f}loÄ STR_8106_MONORAIL_LOCOMOTIVE :{G=f}lokomotiva pro monorail STR_8106_MONORAIL_LOCOMOTIVE.acc :{G=f}lokomotivu pro monorail +STR_8106_MONORAIL_LOCOMOTIVE.dat :{G=f}lokomotivu pro monorail STR_8107_MAGLEV_LOCOMOTIVE :{G=f}lokomotiva Maglev STR_8107_MAGLEV_LOCOMOTIVE.acc :{G=f}lokomotivu Maglev +STR_8107_MAGLEV_LOCOMOTIVE.dat :{G=f}lokomotivu Maglev ##id 0x8800 STR_8800_TRAIN_DEPOT :{WHITE}ŽelezniÄní depo {TOWN} diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/danish.txt --- a/src/lang/danish.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/danish.txt Wed Feb 28 00:33:40 2007 +0000 @@ -1584,6 +1584,8 @@ STR_1816_TREE_LINED_ROAD :Vej med vejtræer STR_1817_ROAD_VEHICLE_DEPOT :Værksted STR_1818_ROAD_RAIL_LEVEL_CROSSING :Jernbaneoverskæring +STR_CAN_T_REMOVE_BUS_STATION :{WHITE}Kan ikke fjerne rutebilstation... +STR_CAN_T_REMOVE_TRUCK_STATION :{WHITE}Kan ikke fjerne fragtcentral... ##id 0x2000 STR_2000_TOWNS :{WHITE}Byer @@ -2877,7 +2879,7 @@ STR_PERFORMANCE_DETAIL_TOTAL :{BLACK}Total: ############ End of order list STR_PERFORMANCE_DETAIL_VEHICLES_TIP :{BLACK}Antal af køretøjer; dette inkludere vejkøretøjer, tog, skibe og fly -STR_PERFORMANCE_DETAIL_STATIONS_TIP :{BLACK}Antallet af stationer. Alle dele af en station (f.eks. tog station, bus station, lufthavn) tæller med, ogsÃ¥ selvom de er sat sammen til en station +STR_PERFORMANCE_DETAIL_STATIONS_TIP :{BLACK}Antallet af stationer. Alle dele af en station (f.eks. banegÃ¥rd, rutebilstation, lufthavn) tæller med, selvom de er sammensat som én station STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP :{BLACK}Afkast for køretøjet med laveste indkomst (af alle køretøjer ældre end 2 Ã¥r) STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP :{BLACK}Indtægt i mÃ¥neden med den laveste indtægt i de sidste 12 kvartaler STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP :{BLACK}Indkomst i mÃ¥neden med det højeste afkast i de sidste 12 kvartaler diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/english.txt --- a/src/lang/english.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/english.txt Wed Feb 28 00:33:40 2007 +0000 @@ -2901,6 +2901,17 @@ STR_NEWGRF_MD5SUM :{BLACK}MD5sum: {SILVER}{STRING} STR_NEWGRF_CONFIRMATION_TEXT :{YELLOW}You are about to make changes to a running game; this can crash OpenTTD.{}Are you absolutely sure about this? +STR_NEWGRF_ERROR_MSG_INFO :{SILVER}{STRING} +STR_NEWGRF_ERROR_MSG_WARNING :{RED}Warning: {SILVER}{STRING} +STR_NEWGRF_ERROR_MSG_ERROR :{RED}Error: {SILVER}{STRING} +STR_NEWGRF_ERROR_MSG_FATAL :{RED}Fatal: {SILVER}{STRING} +STR_NEWGRF_ERROR_VERSION_NUMBER :{STRING} will not work with the TTDPatch version reported by OpenTTD. +STR_NEWGRF_ERROR_DOS_OR_WINDOWS :{STRING} is for the {STRING} version of TTD. +STR_NEWGRF_ERROR_UNSET_SWITCH :{STRING} is designed to be used with {STRING} +STR_NEWGRF_ERROR_INVALID_PARAMETER :Invalid parameter for {STRING}: parameter {STRING} ({NUM}) +STR_NEWGRF_ERROR_LOAD_BEFORE :{STRING} must be loaded before {STRING}. +STR_NEWGRF_ERROR_LOAD_AFTER :{STRING} must be loaded after {STRING}. + STR_NEWGRF_ADD :{BLACK}Add STR_NEWGRF_ADD_TIP :{BLACK}Add a NewGRF file to the list STR_NEWGRF_REMOVE :{BLACK}Remove diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/finnish.txt --- a/src/lang/finnish.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/finnish.txt Wed Feb 28 00:33:40 2007 +0000 @@ -2192,7 +2192,6 @@ STR_707F_HAS_BEEN_TAKEN_OVER_BY :{BLACK}{BIGFONT}Yhtiön {COMPANY} on ottanut haltuun {COMPANY}! STR_7080_PROTECTED :{WHITE}Tällä yhtiöllä ei ole vielä osakkeita... -STR_LIVERY_DEFAULT : STR_LIVERY_STEAM :Höyryveturi STR_LIVERY_DIESEL :Dieselveturi STR_LIVERY_ELECTRIC :Sähköveturi diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/french.txt --- a/src/lang/french.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/french.txt Wed Feb 28 00:33:40 2007 +0000 @@ -1314,7 +1314,7 @@ STR_NETWORK_SERVER_OFFLINE :{SILVER}SERVEUR HORS-LIGNE STR_NETWORK_SERVER_FULL :{SILVER}SERVEUR PLEIN STR_NETWORK_VERSION_MISMATCH :{SILVER}VERSION NON CORRESPONDANTE -STR_NETWORK_GRF_MISMATCH :{SILVER}NEWGRF DIFFERENTS +STR_NETWORK_GRF_MISMATCH :{SILVER}NEWGRF REQUIS STR_NETWORK_JOIN_GAME :{BLACK}Rejoindre la partie diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/korean.txt --- a/src/lang/korean.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/korean.txt Wed Feb 28 00:33:40 2007 +0000 @@ -1042,6 +1042,7 @@ STR_CONFIG_PATCHES_NONUNIFORM_STATIONS :{LTBLUE}ì´ë¯¸ 지어진 ì—­ì— ì¶”ê°€ë¡œ ì—­ì„ ì¦ì¶•하는 ê²ƒì„ í—ˆìš© : {ORANGE}{STRING} STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL :{LTBLUE}í–¥ìƒëœ 글로벌 경로íƒìƒ‰ (NPF, NTP ìš°ì„ ) : {ORANGE}{STRING} STR_CONFIG_PATCHES_FREIGHT_TRAINS :{LTBLUE}무거운 열차를 운행하기 위해 í™”ë¬¼ì— ë¬´ê²Œë¥¼ 가함 : {ORANGE}{STRING} +STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD :{LTBLUE}마ì„ì´ ì†Œìœ ì¤‘ì¸ ë„로를 통과하는 버스 정류장 건설 허용: {ORANGE}{STRING} STR_CONFIG_PATCHES_SMALL_AIRPORTS :{LTBLUE}소형 ê³µí•­ì˜ ê±´ì„¤ì„ í—ˆìš© : {ORANGE}{STRING} @@ -1585,6 +1586,8 @@ STR_1816_TREE_LINED_ROAD :가로수가 있는 ë„로 STR_1817_ROAD_VEHICLE_DEPOT :차고 STR_1818_ROAD_RAIL_LEVEL_CROSSING :ì² ë„ ê±´ë„목 +STR_CAN_T_REMOVE_BUS_STATION :{WHITE}ë²„ìŠ¤ì •ë¥˜ìž¥ì„ ì œê±°í•  수 없습니다... +STR_CAN_T_REMOVE_TRUCK_STATION :{WHITE}트럭 터미ë„ì„ ì œê±°í•  수 없습니다... ##id 0x2000 STR_2000_TOWNS :{WHITE}ë„시 diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/portuguese.txt --- a/src/lang/portuguese.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/portuguese.txt Wed Feb 28 00:33:40 2007 +0000 @@ -606,9 +606,9 @@ STR_0214_ENTREPRENEUR :Empresário STR_0215_INDUSTRIALIST :Industrial STR_0216_CAPITALIST :Capitalista -STR_0217_MAGNATE :Magnate -STR_0218_MOGUL :Grande magnate -STR_0219_TYCOON_OF_THE_CENTURY :Magnate do século +STR_0217_MAGNATE :Magnata +STR_0218_MOGUL :Grande magnata +STR_0219_TYCOON_OF_THE_CENTURY :Magnata do século STR_HIGHSCORE_NAME :{BIGFONT}{PLAYERNAME}, {COMPANY} STR_HIGHSCORE_STATS :{BIGFONT}'{STRING}' ({COMMA}) STR_021B_ACHIEVES_STATUS :{BLACK}{BIGFONT}{COMPANY} conquista '{STRING}' desempenho! @@ -1039,7 +1039,7 @@ STR_CONFIG_PATCHES_AUTOSCROLL :{LTBLUE}Deslocar janela quando o rato está na borda do mapa: {ORANGE}{STRING} STR_CONFIG_PATCHES_BRIBE :{LTBLUE}Permitir o suborno da autoridade local: {ORANGE}{STRING} STR_CONFIG_PATCHES_NONUNIFORM_STATIONS :{LTBLUE}Estações não uniformes: {ORANGE}{STRING} -STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL :{LTBLUE}Nova procura de caminho global (NPF, overrides NTP): {ORANGE}{STRING} +STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL :{LTBLUE}Nova procura de caminho global (NPF, substitui NTP): {ORANGE}{STRING} STR_CONFIG_PATCHES_FREIGHT_TRAINS :{LTBLUE}Multiplicador de peso para simular comboios pesados: {ORANGE}{STRING} STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD :{LTBLUE}Permitir estações de passagem em estradas das cidades: {ORANGE}{STRING} diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/romanian.txt --- a/src/lang/romanian.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/romanian.txt Wed Feb 28 00:33:40 2007 +0000 @@ -295,6 +295,7 @@ STR_0141_LOAD_GAME :{BLACK}ÃŽncarcã joc STR_SINGLE_PLAYER :{BLACK}Un singur jucãtor STR_MULTIPLAYER :{BLACK}Multiplayer +STR_SCENARIO_EDITOR :{BLACK}Editor harta STR_64 :64 STR_128 :128 @@ -390,6 +391,7 @@ STR_ENGINE_SORT_INTRO_DATE :Data lansarii STR_ENGINE_SORT_RUNNING_COST :Cost exploatare STR_ENGINE_SORT_POWER_VS_RUNNING_COST :Cost exploatare/putere +STR_ENGINE_SORT_CARGO_CAPACITY : STR_NO_WAITING_CARGO :{BLACK}Nu este în asteptare nici un fel de încãrcãturã STR_SELECT_ALL_FACILITIES :{BLACK}Alege toate facilitãtile STR_SELECT_ALL_TYPES :{BLACK}Alege toate tipurile de încãrcãturi (inclusiv încãrcãturile care nu sunt în asteptare) @@ -622,6 +624,8 @@ STR_022A_GENERATE_RANDOM_LAND :{BLACK}Genereazã teren aleator STR_022B_RESET_LANDSCAPE :{BLACK}Reseteazã peisajul STR_022C_RESET_LANDSCAPE :{WHITE}Resetare peisaj +STR_RESET_LANDSCAPE_TOOLTIP :{BLACK}Elimina de pe harta toate proprietatile detinute de jucatori +STR_RESET_LANDSCAPE_CONFIRMATION_TEXT :{WHITE}Esti sigur ca vrei sa elimini toate proprietatile detinute de jucatori? STR_022E_LANDSCAPE_GENERATION :{BLACK}Generare peisaj STR_022F_TOWN_GENERATION :{BLACK}Generare oras STR_0230_INDUSTRY_GENERATION :{BLACK}Generare industrii @@ -726,6 +730,7 @@ STR_0291_DELETE_THIS_TOWN_COMPLETELY :{BLACK}Sterge acest oras STR_0292_SAVE_SCENARIO :Salveazã scenariul STR_0293_LOAD_SCENARIO :ÃŽncarcã scenariu +STR_LOAD_HEIGHTMAP :Incarca harta de inaltimi STR_0294_QUIT_EDITOR :Iesire din editor STR_0295 : STR_0296_QUIT :Iesire din joc @@ -1036,6 +1041,7 @@ STR_CONFIG_PATCHES_NONUNIFORM_STATIONS :{LTBLUE}Statii neuniforme: {ORANGE}{STRING} STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL :{LTBLUE}Nou pathfinding global(NPF, dezactiveaza NTP): {ORANGE}{STRING} STR_CONFIG_PATCHES_FREIGHT_TRAINS :{LTBLUE}Multiplicator greutate pt marfar pt simularea trenurilor grele: {ORANGE}{STRING} +STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD :{LTBLUE}Permite semafoare in intersectiile drumurilor din proprietatea orasului: {ORANGE}{STRING} STR_CONFIG_PATCHES_SMALL_AIRPORTS :{LTBLUE}Permite întotdeauna aeroporturi mici: {ORANGE}{STRING} @@ -1412,6 +1418,7 @@ STR_NETWORK_ERR_NOTAVAILABLE :{WHITE}Nu a fost detectatã o placã de retea valabilã STR_NETWORK_ERR_NOSERVER :{WHITE}Nu a fost gãsit nici un joc în retea STR_NETWORK_ERR_NOCONNECTION :{WHITE}Serverul nu a rãspuns cererii +STR_NETWORK_ERR_NEWGRF_MISMATCH :{WHITE} Nu m-am putut conecta din cauza unei nepotriviri NewGRF STR_NETWORK_ERR_DESYNC :{WHITE} Sincronizarea jocului in retea a esuat. STR_NETWORK_ERR_LOSTCONNECTION :{WHITE} Conexiunea jocului in reatea a fost intrerupta. STR_NETWORK_ERR_SAVEGAMEERROR :{WHITE} Nu am reusit sa incarc jocul-server salvat. @@ -1433,6 +1440,7 @@ STR_NETWORK_ERR_CLIENT_SAVEGAME :nu pot incarca harta STR_NETWORK_ERR_CLIENT_CONNECTION_LOST :conexiune pierduta STR_NETWORK_ERR_CLIENT_PROTOCOL_ERROR :eroare de protocol +STR_NETWORK_ERR_CLIENT_NEWGRF_MISMATCH :Nepotrivire NewGRF STR_NETWORK_ERR_CLIENT_NOT_AUTHORIZED :neautorizat STR_NETWORK_ERR_CLIENT_NOT_EXPECTED :primit pachet ciudat STR_NETWORK_ERR_CLIENT_WRONG_REVISION :versiune incorecta @@ -1577,6 +1585,8 @@ STR_1816_TREE_LINED_ROAD :Stradã cu copaci pe margine STR_1817_ROAD_VEHICLE_DEPOT :Autobazã STR_1818_ROAD_RAIL_LEVEL_CROSSING :Traversare la nivel cu calea feratã +STR_CAN_T_REMOVE_BUS_STATION :{WHITE}Nu pot elimina statia de autobus... +STR_CAN_T_REMOVE_TRUCK_STATION :{WHITE}Nu pot elimina statia de camioane... ##id 0x2000 STR_2000_TOWNS :{WHITE}Orase @@ -2663,6 +2673,7 @@ STR_9023_BUILD_NEW_ROAD_VEHICLE :{BLACK}Cumpãrã un autovehicul STR_9024_DRAG_ROAD_VEHICLE_TO_HERE :{BLACK}Mutã un autovehicul aici pentru a-l vinde STR_9025_CENTER_MAIN_VIEW_ON_ROAD :{BLACK}Centreazã imaginea pe locatia acestei autobaze +STR_9026_ROAD_VEHICLE_SELECTION :{BLACK}Lista selectie vehicule rutiere - apasa pe vehicul pentru informatii STR_9027_BUILD_THE_HIGHLIGHTED_ROAD :{BLACK}Cumpãrã autovehiculul selectat STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE :{BLACK}{BIGFONT}Un nou autovehicul disponibil! STR_9029 :{BLACK}{BIGFONT}{STRING} diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/russian.txt --- a/src/lang/russian.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/russian.txt Wed Feb 28 00:33:40 2007 +0000 @@ -1018,45 +1018,45 @@ STR_CONFIG_PATCHES_VEHICLESPEED :{LTBLUE}Показывать ÑкороÑть в панели ÑтатуÑа транÑпорта: {ORANGE}{STRING} STR_CONFIG_PATCHES_BUILDONSLOPES :{LTBLUE}Разрешить ÑтроительÑтво на Ñклонах и берегу: {ORANGE}{STRING} STR_CONFIG_PATCHES_CATCHMENT :{LTBLUE}Разрешить более реалиÑтичные зоны покрытиÑ: {ORANGE}{STRING} -STR_CONFIG_PATCHES_EXTRADYNAMITE :{LTBLUE}Разрешить удалÑть больше дорог, моÑтов, Ñ‚.п.: {ORANGE}{STRING} -STR_CONFIG_PATCHES_MAMMOTHTRAINS :{LTBLUE}ИÑпользовать очень длинные поезда: {ORANGE}{STRING} -STR_CONFIG_PATCHES_REALISTICACCEL :{LTBLUE}Разрешить реалиÑтичное уÑкорение: {ORANGE}{STRING} -STR_CONFIG_PATCHES_FORBID_90_DEG :{LTBLUE}Запретить повороты на 90 град.: {ORANGE}{STRING} {LTBLUE} (требуетÑÑ NPF) -STR_CONFIG_PATCHES_JOINSTATIONS :{LTBLUE}ОбъединÑть Ñтанции: {ORANGE}{STRING} -STR_CONFIG_PATCHES_FULLLOADANY :{LTBLUE}При вкл. полной загрузке отправлÑтьÑÑ, когда заполнен один тип вагонов: {ORANGE}{STRING} -STR_CONFIG_PATCHES_IMPROVEDLOAD :{LTBLUE}Улучшенный алгоритм загрузки: {ORANGE}{STRING} +STR_CONFIG_PATCHES_EXTRADYNAMITE :{LTBLUE}Разрешить удаление вÑех принадлежащих городу объектов: {ORANGE}{STRING} +STR_CONFIG_PATCHES_MAMMOTHTRAINS :{LTBLUE}Включить ÑтроительÑтво очень длинных поездов: {ORANGE}{STRING} +STR_CONFIG_PATCHES_REALISTICACCEL :{LTBLUE}Включить реалиÑтичное уÑкорение Ð´Ð»Ñ Ð¿Ð¾ÐµÐ·Ð´Ð¾Ð²: {ORANGE}{STRING} +STR_CONFIG_PATCHES_FORBID_90_DEG :{LTBLUE}Запретить резкие повороты поездам и кораблÑм: {ORANGE}{STRING} {LTBLUE}(NPF) +STR_CONFIG_PATCHES_JOINSTATIONS :{LTBLUE}ОбъединÑть поÑтроенные Ñ€Ñдом Ñтанции: {ORANGE}{STRING} +STR_CONFIG_PATCHES_FULLLOADANY :{LTBLUE}Покидать Ñтанцию, когда любой груз полноÑтью загружен: {ORANGE}{STRING} +STR_CONFIG_PATCHES_IMPROVEDLOAD :{LTBLUE}ИÑпользовать улучшенный алгоритм загрузки: {ORANGE}{STRING} STR_CONFIG_PATCHES_GRADUAL_LOADING :{LTBLUE}ПоÑÑ‚ÐµÐ¿ÐµÐ½Ð½Ð°Ñ Ð·Ð°Ð³Ñ€ÑƒÐ·ÐºÐ° транÑпорта: {ORANGE}{STRING} STR_CONFIG_PATCHES_INFLATION :{LTBLUE}ИнфлÑциÑ: {ORANGE}{STRING} STR_CONFIG_PATCHES_SELECTGOODS :{LTBLUE}ДоÑтавлÑть груз на Ñтанцию, только еÑли она его принимает: {ORANGE}{STRING} -STR_CONFIG_PATCHES_LONGBRIDGES :{LTBLUE}Строить очень длинные моÑты: {ORANGE}{STRING} -STR_CONFIG_PATCHES_GOTODEPOT :{LTBLUE}ДобавлÑть депо в раÑпиÑание: {ORANGE}{STRING} +STR_CONFIG_PATCHES_LONGBRIDGES :{LTBLUE}Разрешить ÑтроительÑтво очень длинных моÑтов: {ORANGE}{STRING} +STR_CONFIG_PATCHES_GOTODEPOT :{LTBLUE}Разрешить добавлÑть депо в маршрут: {ORANGE}{STRING} STR_CONFIG_PATCHES_BUILDXTRAIND :{LTBLUE}Разрешить ÑтроительÑтво Ñырьевых предприÑтий: {ORANGE}{STRING} STR_CONFIG_PATCHES_MULTIPINDTOWN :{LTBLUE}Строить неÑк. предприÑтий 1 типа в одном городе: {ORANGE}{STRING} STR_CONFIG_PATCHES_SAMEINDCLOSE :{LTBLUE}Одинаковые предприÑÑ‚Ð¸Ñ Ð¼Ð¾Ð¶Ð½Ð¾ Ñтроить Ñ€Ñдом: {ORANGE}{STRING} STR_CONFIG_PATCHES_LONGDATE :{LTBLUE}Ð’Ñегда показывать длинную дату в панели ÑоÑтоÑниÑ: {ORANGE}{STRING} -STR_CONFIG_PATCHES_SIGNALSIDE :{LTBLUE}Сигналы на Ñтороне движениÑ: {ORANGE}{STRING} +STR_CONFIG_PATCHES_SIGNALSIDE :{LTBLUE}Показывать Ñветофоры на Ñтороне движениÑ: {ORANGE}{STRING} STR_CONFIG_PATCHES_SHOWFINANCES :{LTBLUE}Показывать финанÑовую ÑтатиÑтику в конце года: {ORANGE}{STRING} -STR_CONFIG_PATCHES_NEW_NONSTOP :{LTBLUE}Приказ без оÑтановки в Ñтиле TTDPatch: {ORANGE}{STRING} -STR_CONFIG_PATCHES_ROADVEH_QUEUE :{LTBLUE}Разрешить ожидание въезда на автоÑтанцию: {ORANGE}{STRING} +STR_CONFIG_PATCHES_NEW_NONSTOP :{LTBLUE}ИÑпользовать поведение TTDP Ð´Ð»Ñ Ð¿Ñ€Ð¸ÐºÐ°Ð·Ð° "без оÑтановок": {ORANGE}{STRING} +STR_CONFIG_PATCHES_ROADVEH_QUEUE :{LTBLUE}Разрешить автомобилÑм ожидать въезда на Ñтанцию: {ORANGE}{STRING} STR_CONFIG_PATCHES_AUTOSCROLL :{LTBLUE}Смещать обзор, когда курÑор находитÑÑ Ñƒ ÐºÑ€Ð°Ñ Ñкрана: {ORANGE}{STRING} STR_CONFIG_PATCHES_BRIBE :{LTBLUE}Разрешить взÑтку меÑтной админиÑтрации: {ORANGE}{STRING} -STR_CONFIG_PATCHES_NONUNIFORM_STATIONS :{LTBLUE}Станции могут быть разной формы: {ORANGE}{STRING} -STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL :{LTBLUE}Ðовый поиÑк пути (NPF, без NTP): {ORANGE}{STRING} -STR_CONFIG_PATCHES_FREIGHT_TRAINS :{LTBLUE}КоÑÑ„. ÑƒÐ²ÐµÐ»Ð¸Ñ‡ÐµÐ½Ð¸Ñ Ð²ÐµÑа груза: {ORANGE}{STRING} +STR_CONFIG_PATCHES_NONUNIFORM_STATIONS :{LTBLUE}Станции могут быть произвольной формы: {ORANGE}{STRING} +STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL :{LTBLUE}Включить новый алгоритм навигации (NPF, заменÑет NTP): {ORANGE}{STRING} +STR_CONFIG_PATCHES_FREIGHT_TRAINS :{LTBLUE}Множитель ÑƒÐ²ÐµÐ»Ð¸Ñ‡ÐµÐ½Ð¸Ñ Ð²ÐµÑа груза Ð´Ð»Ñ Ñ‚Ð¾Ð²Ð°Ñ€Ð½Ñ‹Ñ… поездов: {ORANGE}{STRING} STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD :{LTBLUE}ПозволÑть Ñтроить Ñквозные оÑтановки на городÑких дорогах: {ORANGE}{STRING} -STR_CONFIG_PATCHES_SMALL_AIRPORTS :{LTBLUE}Ð’Ñегда разрешать малые аÑропорты: {ORANGE}{STRING} +STR_CONFIG_PATCHES_SMALL_AIRPORTS :{LTBLUE}Ð’Ñегда разрешать ÑтроительÑтво малых аÑропортов: {ORANGE}{STRING} -STR_CONFIG_PATCHES_WARN_LOST_TRAIN :{LTBLUE}Предупреждать, еÑли поезд не находит дороги: {ORANGE}{STRING} -STR_CONFIG_PATCHES_ORDER_REVIEW :{LTBLUE}ПереÑмотреть раÑпиÑаниÑ: {ORANGE}{STRING} +STR_CONFIG_PATCHES_WARN_LOST_TRAIN :{LTBLUE}Предупреждать, еÑли поезд заблудилÑÑ: {ORANGE}{STRING} +STR_CONFIG_PATCHES_ORDER_REVIEW :{LTBLUE}ПроверÑть маршруты транÑпортных ÑредÑтв на правильноÑть: {ORANGE}{STRING} STR_CONFIG_PATCHES_ORDER_REVIEW_OFF :нет STR_CONFIG_PATCHES_ORDER_REVIEW_EXDEPOT :да, кроме оÑтановленных транÑп. ÑредÑтв STR_CONFIG_PATCHES_ORDER_REVIEW_ON :вÑего транÑпорта -STR_CONFIG_PATCHES_WARN_INCOME_LESS :{LTBLUE}Предупреждать, что транÑп. ÑредÑтво приноÑит убыток: {ORANGE}{STRING} +STR_CONFIG_PATCHES_WARN_INCOME_LESS :{LTBLUE}Предупреждать, еÑли поезд приноÑит убыток: {ORANGE}{STRING} STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES :{LTBLUE}ТранÑпорт никогда не уÑтаревает: {ORANGE}{STRING} -STR_CONFIG_PATCHES_AUTORENEW_VEHICLE :{LTBLUE}ÐвтоматичеÑки обновлÑть уÑтаревший транÑпорт -STR_CONFIG_PATCHES_AUTORENEW_MONTHS :{LTBLUE}Обновить транÑпорт за (через) {ORANGE}{STRING}{LTBLUE} меÑ. поÑле уÑÑ‚Ð°Ñ€ÐµÐ²Ð°Ð½Ð¸Ñ -STR_CONFIG_PATCHES_AUTORENEW_MONEY :{LTBLUE}ÐœÐ¸Ð½Ð¸Ð¼Ð°Ð»ÑŒÐ½Ð°Ñ Ñумма Ð´Ð»Ñ Ð°Ð²Ñ‚Ð¾Ð¾Ð±Ð½Ð¾Ð²Ð»ÐµÐ½Ð¸Ñ: {ORANGE}{STRING} +STR_CONFIG_PATCHES_AUTORENEW_VEHICLE :{LTBLUE}ÐвтоматичеÑки обновлÑть изношенный транÑпорт +STR_CONFIG_PATCHES_AUTORENEW_MONTHS :{LTBLUE}ОбновлÑть через {ORANGE}{STRING}{LTBLUE} меÑÑцев поÑле иÑÑ‚ÐµÑ‡ÐµÐ½Ð¸Ñ Ñрока Ñлужбы +STR_CONFIG_PATCHES_AUTORENEW_MONEY :{LTBLUE}ÐœÐ¸Ð½Ð¸Ð¼Ð°Ð»ÑŒÐ½Ð°Ñ Ñумма, Ð½ÐµÐ¾Ð±Ñ…Ð¾Ð´Ð¸Ð¼Ð°Ñ Ð´Ð»Ñ Ð°Ð²Ñ‚Ð¾Ð¾Ð±Ð½Ð¾Ð²Ð»ÐµÐ½Ð¸Ñ: {ORANGE}{STRING} STR_CONFIG_PATCHES_ERRMSG_DURATION :{LTBLUE}ДлительноÑть Ñообщений об ошибке: {ORANGE}{STRING} STR_CONFIG_PATCHES_POPULATION_IN_LABEL :{LTBLUE}Показывать количеÑтво жителей города поÑле названиÑ: {ORANGE}{STRING} STR_CONFIG_PATCHES_INVISIBLE_TREES :{LTBLUE}Убирать Ð´ÐµÑ€ÐµÐ²ÑŒÑ Ð¿Ñ€Ð¸ включении прозрачноÑти зданий: {ORANGE}{STRING} @@ -1064,7 +1064,7 @@ STR_CONFIG_PATCHES_LAND_GENERATOR :{LTBLUE}Генератор земли: {ORANGE}{STRING} STR_CONFIG_PATCHES_LAND_GENERATOR_ORIGINAL :Оригинальный STR_CONFIG_PATCHES_LAND_GENERATOR_TERRA_GENESIS :TerraGenesis -STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE :{LTBLUE}МакÑ. диÑÑ‚Ð°Ð½Ñ†Ð¸Ñ Ð¾Ñ‚ ÐºÑ€Ð°Ñ ÐºÐ°Ñ€Ñ‚Ñ‹ до Ðефтепер. завода {ORANGE}{STRING} +STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE :{LTBLUE}МакÑ. раÑÑтоÑние от ÐºÑ€Ð°Ñ ÐºÐ°Ñ€Ñ‚Ñ‹ до нефтепер. заводов: {ORANGE}{STRING} STR_CONFIG_PATCHES_SNOWLINE_HEIGHT :{LTBLUE}Ð’Ñ‹Ñота "Ñнежной" линии: {ORANGE}{STRING} STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN :{LTBLUE}ÐеровноÑть земли (только Ð´Ð»Ñ TerraGenesis) : {ORANGE}{STRING} STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :Очень гладкий @@ -1091,38 +1091,38 @@ STR_CONFIG_PATCHES_LIVERIES_ALL :Ð´Ð»Ñ Ð²Ñех компаний STR_CONFIG_PATCHES_PREFER_TEAMCHAT :{LTBLUE}Предпочитать командный чат при нажатии Enter: {ORANGE}{STRING} -STR_CONFIG_PATCHES_MAX_TRAINS :{LTBLUE}МакÑ. кол-во поездов у игрока: {ORANGE}{STRING} -STR_CONFIG_PATCHES_MAX_ROADVEH :{LTBLUE}МакÑ. кол-во автотранÑпорта у игрока: {ORANGE}{STRING} -STR_CONFIG_PATCHES_MAX_AIRCRAFT :{LTBLUE}МакÑ. кол-во авиатранÑпорта у игрока: {ORANGE}{STRING} -STR_CONFIG_PATCHES_MAX_SHIPS :{LTBLUE}МакÑ. кол-во кораблей у игрока: {ORANGE}{STRING} +STR_CONFIG_PATCHES_MAX_TRAINS :{LTBLUE}МакÑимальное количеÑтво поездов у игрока: {ORANGE}{STRING} +STR_CONFIG_PATCHES_MAX_ROADVEH :{LTBLUE}МакÑимальное количеÑтво кол-во автомобилей у игрока: {ORANGE}{STRING} +STR_CONFIG_PATCHES_MAX_AIRCRAFT :{LTBLUE}МакÑимальное количеÑтво авиатранÑпорта у игрока: {ORANGE}{STRING} +STR_CONFIG_PATCHES_MAX_SHIPS :{LTBLUE}МакÑимальное количеÑтво кораблей у игрока: {ORANGE}{STRING} STR_CONFIG_PATCHES_AI_BUILDS_TRAINS :{LTBLUE}Ðе допуÑкать поÑтройки поездов конкурентами: {ORANGE}{STRING} STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH :{LTBLUE}Ðе допуÑкать поÑтройки автомобилей конкурентами: {ORANGE}{STRING} -STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT :{LTBLUE}Ðе допуÑкать поÑтройки Ñамолётов конкурентами: {ORANGE}{STRING} +STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT :{LTBLUE}Ðе допуÑкать поÑтройки авиатранÑпорта конкурентами: {ORANGE}{STRING} STR_CONFIG_PATCHES_AI_BUILDS_SHIPS :{LTBLUE}Ðе допуÑкать поÑтройки кораблей конкурентами: {ORANGE}{STRING} STR_CONFIG_PATCHES_AINEW_ACTIVE :{LTBLUE}Включить новый AI (альфа-верÑиÑ): {ORANGE}{STRING} STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER :{LTBLUE}Разрешить поÑвление AI-конкурентов в Ñетевой игре: {ORANGE}{STRING} STR_CONFIG_PATCHES_SERVINT_TRAINS :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð¿Ð¾ÐµÐ·Ð´Ð¾Ð²: {ORANGE}{STRING} дней/% -STR_CONFIG_PATCHES_SERVINT_TRAINS_DISABLED :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð¿Ð¾ÐµÐ·Ð´Ð¾Ð²: {ORANGE}отключено -STR_CONFIG_PATCHES_SERVINT_ROADVEH :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð°Ð²Ñ‚Ð¾Ñ‚Ñ€Ð°Ð½Ñпорта: {ORANGE}{STRING} дней/% -STR_CONFIG_PATCHES_SERVINT_ROADVEH_DISABLED :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð°Ð²Ñ‚Ð¾Ñ‚Ñ€Ð°Ð½Ñпорта: {ORANGE}отключено -STR_CONFIG_PATCHES_SERVINT_AIRCRAFT :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ñамолетов: {ORANGE}{STRING} дней/% -STR_CONFIG_PATCHES_SERVINT_AIRCRAFT_DISABLED :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ñамолетов: {ORANGE}отключено +STR_CONFIG_PATCHES_SERVINT_TRAINS_DISABLED :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð¿Ð¾ÐµÐ·Ð´Ð¾Ð²: {ORANGE}не обÑлуживаютÑÑ +STR_CONFIG_PATCHES_SERVINT_ROADVEH :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð°Ð²Ñ‚Ð¾Ð¼Ð¾Ð±Ð¸Ð»ÐµÐ¹: {ORANGE}{STRING} дней/% +STR_CONFIG_PATCHES_SERVINT_ROADVEH_DISABLED :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð°Ð²Ñ‚Ð¾Ð¼Ð¾Ð±Ð¸Ð»ÐµÐ¹: {ORANGE}не обÑлуживаютÑÑ +STR_CONFIG_PATCHES_SERVINT_AIRCRAFT :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð°Ð²Ð¸Ð°Ñ‚Ñ€Ð°Ð½Ñпорта: {ORANGE}{STRING} дней/% +STR_CONFIG_PATCHES_SERVINT_AIRCRAFT_DISABLED :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð°Ð²Ð¸Ð°Ñ‚Ñ€Ð°Ð½Ñпорта: {ORANGE}не обÑлуживаетÑÑ STR_CONFIG_PATCHES_SERVINT_SHIPS :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ ÐºÐ¾Ñ€Ð°Ð±Ð»ÐµÐ¹: {ORANGE}{STRING} дней/% -STR_CONFIG_PATCHES_SERVINT_SHIPS_DISABLED :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ ÐºÐ¾Ñ€Ð°Ð±Ð»ÐµÐ¹: {ORANGE}отключено -STR_CONFIG_PATCHES_NOSERVICE :{LTBLUE}Ðе обÑлуживать, еÑли поломки выкл. : {ORANGE}{STRING} +STR_CONFIG_PATCHES_SERVINT_SHIPS_DISABLED :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ ÐºÐ¾Ñ€Ð°Ð±Ð»ÐµÐ¹: {ORANGE}не обÑлуживаютÑÑ +STR_CONFIG_PATCHES_NOSERVICE :{LTBLUE}Отключить обÑлуживание, еÑли поломки выключены: {ORANGE}{STRING} STR_CONFIG_PATCHES_WAGONSPEEDLIMITS :{LTBLUE}Включить ограничение ÑкороÑти вагонов: {ORANGE}{STRING} -STR_CONFIG_PATCHES_DISABLE_ELRAILS :{LTBLUE}Откл. Ñлектрофицир. ЖД: {ORANGE}{STRING} +STR_CONFIG_PATCHES_DISABLE_ELRAILS :{LTBLUE}Отключить Ñлектрофицированную железную дорогу: {ORANGE}{STRING} STR_CONFIG_PATCHES_COLORED_NEWS_YEAR :{LTBLUE}"Цветные" новоÑти поÑвл. в : {ORANGE}{STRING} STR_CONFIG_PATCHES_STARTING_YEAR :{LTBLUE}Год начала игры: {ORANGE}{STRING} STR_CONFIG_PATCHES_ENDING_YEAR :{LTBLUE}Год Ð¾ÐºÐ¾Ð½Ñ‡Ð°Ð½Ð¸Ñ Ð¸Ð³Ñ€Ñ‹: {ORANGE}{STRING} STR_CONFIG_PATCHES_SMOOTH_ECONOMY :{LTBLUE}Включить плавную Ñкономику (более мелкие изменениÑ) STR_CONFIG_PATCHES_ALLOW_SHARES :{LTBLUE}Разрешить покупку акций других компаний -STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY :{LTBLUE}При перетаÑкивании Ñтавить Ñигналы каждые : {ORANGE}{STRING} клетки -STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE :{LTBLUE}ÐвтоматичеÑки Ñтроить Ñемафоры до: {ORANGE}{STRING} +STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY :{LTBLUE}При перетаÑкивании Ñтавить Ñветофоры каждые: {ORANGE}{STRING} клетки +STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE :{LTBLUE}ÐвтоматичеÑки Ñтроить Ñемафоры: до {ORANGE}{STRING} года STR_CONFIG_PATCHES_TOOLBAR_POS :{LTBLUE}Положение главной панели инÑтрументов: {ORANGE}{STRING} STR_CONFIG_PATCHES_TOOLBAR_POS_LEFT :Ñлева STR_CONFIG_PATCHES_TOOLBAR_POS_CENTER :в центре @@ -1143,9 +1143,9 @@ STR_CONFIG_PATCHES_QUERY_CAPT :{WHITE}Изменить значение STR_CONFIG_PATCHES_SERVICE_INTERVAL_INCOMPATIBLE :{WHITE}Ðекоторые из выбранных интервалов обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð½Ðµ ÑовмеÑтимы Ñ Ð²Ñ‹Ð±Ñ€Ð°Ð½Ð½Ð¾Ð¹ уÑтановкой. ДопуÑкаютÑÑ Ð·Ð½Ð°Ñ‡ÐµÐ½Ð¸Ñ 5-90% или 30-800 дней. -STR_CONFIG_PATCHES_YAPF_SHIPS :{LTBLUE}ИÑп. YAPF Ð´Ð»Ñ ÐºÐ¾Ñ€Ð°Ð±Ð»ÐµÐ¹: {ORANGE}{STRING} -STR_CONFIG_PATCHES_YAPF_ROAD :{LTBLUE}ИÑп. YAPF Ð´Ð»Ñ Ð°Ð²Ñ‚Ð¾: {ORANGE}{STRING} -STR_CONFIG_PATCHES_YAPF_RAIL :{LTBLUE}ИÑп. YAPF Ð´Ð»Ñ Ð¿Ð¾ÐµÐ·Ð´Ð¾Ð²: {ORANGE}{STRING} +STR_CONFIG_PATCHES_YAPF_SHIPS :{LTBLUE}ИÑпользовать YAPF Ð´Ð»Ñ ÐºÐ¾Ñ€Ð°Ð±Ð»ÐµÐ¹: {ORANGE}{STRING} +STR_CONFIG_PATCHES_YAPF_ROAD :{LTBLUE}ИÑпользовать YAPF Ð´Ð»Ñ Ð°Ð²Ñ‚Ð¾Ð¼Ð¾Ð±Ð¸Ð»ÐµÐ¹: {ORANGE}{STRING} +STR_CONFIG_PATCHES_YAPF_RAIL :{LTBLUE}ИÑпользовать YAPF Ð´Ð»Ñ Ð¿Ð¾ÐµÐ·Ð´Ð¾Ð²: {ORANGE}{STRING} STR_TEMPERATE_LANDSCAPE :Умеренный ландшафт STR_SUB_ARCTIC_LANDSCAPE :СубарктичеÑкий ландшафт @@ -1268,7 +1268,7 @@ STR_RAIL_SELECT_TYPE_OF_CARGO_FOR :{BLACK}Выбор типа груза Ð´Ð»Ñ Ð¿ÐµÑ€ÐµÐ²Ð¾Ð·ÐºÐ¸ STR_RAIL_REFIT_TO_CARRY_HIGHLIGHTED :{BLACK}Переоборудование поезда Ð´Ð»Ñ Ð²Ñ‹Ð´ÐµÐ»ÐµÐ½Ð½Ð¾Ð³Ð¾ типа груза STR_RAIL_CAN_T_REFIT_VEHICLE :{WHITE}Ðе могу переоборуд. поезд... -STR_CONFIG_PATCHES_SERVINT_ISPERCENT :{LTBLUE}Интервал обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð² процентах: {ORANGE}{STRING} +STR_CONFIG_PATCHES_SERVINT_ISPERCENT :{LTBLUE}Интервалы обÑÐ»ÑƒÐ¶Ð¸Ð²Ð°Ð½Ð¸Ñ Ð² процентах от Ñрока Ñлужбы: {ORANGE}{STRING} STR_CONFIG_GAME_PRODUCTION :{WHITE}Изменить производительноÑть TEMP_AI_IN_PROGRESS :{WHITE}Добро пожаловать в новый ИИ, он ÑовершенÑтвуетÑÑ. Ð’Ñ‹ должны быть готовы к проблемам. Когда Ñто ÑлучитÑÑ, Ñделайте Ñнимок и отправьте на форум. ÐаÑлаждайтеÑÑŒ! diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/slovenian.txt --- a/src/lang/slovenian.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/slovenian.txt Wed Feb 28 00:33:40 2007 +0000 @@ -2,7 +2,7 @@ ##ownname SlovenÅ¡Äina ##isocode sl_SL ##plural 8 -##case r d t 3sk +##case r d t ##id 0x0000 STR_NULL : @@ -1871,7 +1871,6 @@ STR_4802_COAL_MINE :Premogovnik STR_4802_COAL_MINE.r :Premogovnika STR_4803_POWER_STATION :Termo elektrarna -STR_4803_POWER_STATION.3sk :Termo elektrarni STR_4804_SAWMILL :Žaga STR_4804_SAWMILL.r :Žage STR_4805_FOREST :Gozd diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/spanish.txt --- a/src/lang/spanish.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/spanish.txt Wed Feb 28 00:33:40 2007 +0000 @@ -1042,7 +1042,7 @@ STR_CONFIG_PATCHES_NONUNIFORM_STATIONS :{LTBLUE}Estaciones no uniformes: {ORANGE}{STRING} STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL :{LTBLUE}Nuevo sistema de busq. de rutas global (NPF, anula a NTP): {ORANGE}{STRING} STR_CONFIG_PATCHES_FREIGHT_TRAINS :{LTBLUE}Carga el multiplicador de peso para simular trenes pesados: {ORANGE}{STRING} -STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD :{LTBLUE}Permite conducir en paradas de carretera propiedad de ciudades: {ORANGE}{STRING} +STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD :{LTBLUE}Permite conducir en paradas sobre carreteras de ciudades: {ORANGE}{STRING} STR_CONFIG_PATCHES_SMALL_AIRPORTS :{LTBLUE}Permitir siempre aeropuertos pequeños: {ORANGE}{STRING} diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/ukrainian.txt --- a/src/lang/ukrainian.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/ukrainian.txt Wed Feb 28 00:33:40 2007 +0000 @@ -23,38 +23,55 @@ STR_000E : STR_000F_PASSENGERS :паÑажири STR_000F_PASSENGERS.r :паÑажирів +STR_000F_PASSENGERS.z :паÑажирів STR_0010_COAL :Ð²ÑƒÐ³Ñ–Ð»Ð»Ñ STR_0010_COAL.r :Ð²ÑƒÐ³Ñ–Ð»Ð»Ñ -STR_0011_MAIL :пошту +STR_0010_COAL.z :Ð²ÑƒÐ³Ñ–Ð»Ð»Ñ +STR_0011_MAIL :пошта STR_0011_MAIL.r :пошти -STR_0012_OIL :нафту +STR_0011_MAIL.z :пошту +STR_0012_OIL :нафта STR_0012_OIL.r :нафти -STR_0013_LIVESTOCK :тварин +STR_0012_OIL.z :нафту +STR_0013_LIVESTOCK :тварини STR_0013_LIVESTOCK.r :тварин +STR_0013_LIVESTOCK.z :тварин STR_0014_GOODS :товари STR_0014_GOODS.r :товарів +STR_0014_GOODS.z :товари STR_0015_GRAIN :зерно STR_0015_GRAIN.r :зерна -STR_0016_WOOD :деревину +STR_0015_GRAIN.z :зерно +STR_0016_WOOD :деревина STR_0016_WOOD.r :деревини -STR_0017_IRON_ORE :залізну руду +STR_0016_WOOD.z :деревину +STR_0017_IRON_ORE :залізна руда STR_0017_IRON_ORE.r :залізної руди +STR_0017_IRON_ORE.z :залізну руду STR_0018_STEEL :Ñталь STR_0018_STEEL.r :Ñталі +STR_0018_STEEL.z :Ñталь STR_0019_VALUABLES :коштовноÑті STR_0019_VALUABLES.r :коштовноÑтей -STR_001A_COPPER_ORE :мідну руду +STR_0019_VALUABLES.z :коштовноÑті +STR_001A_COPPER_ORE :мідна руда STR_001A_COPPER_ORE.r :мідної руди -STR_001B_MAIZE :кукурудзу +STR_001A_COPPER_ORE.z :мідну руду +STR_001B_MAIZE :кукурудза STR_001B_MAIZE.r :кукурудзи +STR_001B_MAIZE.z :кукурудзу STR_001C_FRUIT :фрукти STR_001C_FRUIT.r :фруктів +STR_001C_FRUIT.z :фрукти STR_001D_DIAMONDS :діаманти STR_001D_DIAMONDS.r :діамантів +STR_001D_DIAMONDS.z :діаманти STR_001E_FOOD :продукти STR_001E_FOOD.r :продуктів +STR_001E_FOOD.z :продукти STR_001F_PAPER :папір STR_001F_PAPER.r :паперу +STR_001F_PAPER.z :папір STR_0020_GOLD :золото STR_0020_GOLD.r :золота STR_0020_GOLD.z :золото @@ -91,8 +108,8 @@ STR_002B_BATTERIES :батарейки STR_002B_BATTERIES.r :батарейок STR_002B_BATTERIES.z :батарейки -STR_002C_PLASTIC :плаÑтик -STR_002C_PLASTIC.z :плаÑтик +STR_002C_PLASTIC :плаÑтилін +STR_002C_PLASTIC.z :плаÑтилін STR_002D_FIZZY_DRINKS :газована водф STR_002D_FIZZY_DRINKS.r :газованої води STR_002D_FIZZY_DRINKS.z :газовану воду @@ -184,9 +201,8 @@ STR_004B_BATTERY :батарейки STR_004B_BATTERY.r :батарейок STR_004B_BATTERY.z :батарейки -STR_004C_PLASTIC :плаÑтик -STR_004C_PLASTIC.r :плаÑтику -STR_004C_PLASTIC.z :плаÑтик +STR_004C_PLASTIC :плаÑтилін +STR_004C_PLASTIC.z :плаÑтилін STR_004D_FIZZY_DRINK :газована вода STR_004D_FIZZY_DRINK.r :газованої води STR_004D_FIZZY_DRINK.z :газовану воду @@ -267,7 +283,7 @@ STR_00B5_CAN_T_CLEAR_THIS_AREA :{WHITE}Ðеможливо очиÑтити цю ділÑнку... STR_00B6_ORIGINAL_COPYRIGHT :{BLACK}ÐвторÑьке право {COPYRIGHT} 1995 ÐšÑ€Ñ–Ñ Ð¡Ð¾Ð¹Ñ”Ñ€, Ð’ÑÑ– права захищені STR_00B7_VERSION :{BLACK}OpenTTD верÑÑ–Ñ {REV} -STR_00BA_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT}2002-2007 OpenTTD-група +STR_00BA_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT}2002-2007 команда OpenTTD STR_TRANSLATED_BY :{BLACK} Перекладач(Ñ–) - STR_00C5 :{BLACK}{CROSS} @@ -2343,8 +2359,6 @@ STR_LIVERY_ELECTRIC :Електричні потÑги STR_LIVERY_MONORAIL :ÐœÐ¾Ð½Ð¾Ñ€ÐµÐ»ÑŒÑ STR_LIVERY_MAGLEV :ПотÑги на магнітній подушці -STR_LIVERY_DMU : -STR_LIVERY_EMU : STR_LIVERY_PASSENGER_WAGON_STEAM :ПаÑажирÑький вагон (пар) STR_LIVERY_PASSENGER_WAGON_DIESEL :ПаÑажирÑький вагон (дизель) STR_LIVERY_PASSENGER_WAGON_ELECTRIC :ПаÑажирÑький вагон (електричка) diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/unfinished/afrikaans.txt --- a/src/lang/unfinished/afrikaans.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/unfinished/afrikaans.txt Wed Feb 28 00:33:40 2007 +0000 @@ -298,7 +298,6 @@ STR_0148_GAME_OPTIONS :{BLACK}Spel Opsies STR_0150_SOMEONE :iemand{SKIP}{SKIP} -STR_0151_MAP_OF_WORLD : STR_0152_TOWN_DIRECTORY :Stad index STR_0153_SUBSIDIES :Subsidiëe diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/unfinished/croatian.txt --- a/src/lang/unfinished/croatian.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/unfinished/croatian.txt Wed Feb 28 00:33:40 2007 +0000 @@ -396,8 +396,6 @@ STR_MANAGE_LIST :{BLACK}Uredi popis STR_MANAGE_LIST_TIP :{BLACK}PoÅ¡alji upute svim vozilima na ovoj listi STR_REPLACE_VEHICLES :Zamjeni vozila -STR_SEND_ROAD_VEHICLE_TO_DEPOT : -STR_SEND_SHIP_TO_DEPOT : STR_SEND_AIRCRAFT_TO_HANGAR :PoÅ¡alji u hangar STR_SEND_FOR_SERVICING :PoÅ¡alji na servis diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/unfinished/frisian.txt --- a/src/lang/unfinished/frisian.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/unfinished/frisian.txt Wed Feb 28 00:33:40 2007 +0000 @@ -1010,8 +1010,6 @@ STR_3037_POOR :Min STR_3039_GOOD :Goed STR_303A_VERY_GOOD :Hiel Goed -STR_303B_EXCELLENT : -STR_303C_OUTSTANDING : ############ range for rating ends STR_303D :{WHITE}{STRING}: {YELLOW}{STRING} ({COMMA}%) diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/lang/unfinished/greek.txt --- a/src/lang/unfinished/greek.txt Tue Feb 27 23:54:28 2007 +0000 +++ b/src/lang/unfinished/greek.txt Wed Feb 28 00:33:40 2007 +0000 @@ -480,7 +480,6 @@ STR_01FF :{TINYFONT}{BLACK}{DATE_LONG} STR_0200_LAST_MESSAGE_NEWS_REPORT :Τελευταίο μήνυμα/αναφοÏά νέων STR_0201_MESSAGE_SETTINGS :Ρυθμίσεις μηνυμάτων -STR_MESSAGE_HISTORY_MENU : STR_0203_SHOW_LAST_MESSAGE_NEWS :{BLACK}Εμφάνιση τελευταίου μηνÏματος/αναφοÏάς νέων, επιλογές μηνυμάτων STR_0204_MESSAGE_OPTIONS :{WHITE}Επιλογές Μηνυμάτων STR_0205_MESSAGE_TYPES :{BLACK}ΤÏποι μηνυμάτων: diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/macros.h --- a/src/macros.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/macros.h Wed Feb 28 00:33:40 2007 +0000 @@ -18,14 +18,11 @@ #undef max #endif -/* Objective C don't like templates */ -#ifdef __cplusplus template static inline T max(T a, T b) { return a >= b ? a : b; } -#endif static inline int min(int a, int b) { if (a <= b) return a; return b; } @@ -46,44 +43,39 @@ return a; } -static inline int32 BIGMULSS(int32 a, int32 b, int shift) { - return (int32)(((int64)(a) * (int64)(b)) >> (shift)); +static inline int32 BIGMULSS(int32 a, int32 b, int shift) +{ + return (int32)((int64)a * (int64)b >> shift); } -static inline uint32 BIGMULUS(uint32 a, uint32 b, int shift) { - return (uint32)(((uint64)(a) * (uint64)(b)) >> (shift)); +static inline uint32 BIGMULUS(uint32 a, uint32 b, int shift) +{ + return (uint32)((uint64)a * (uint64)b >> shift); } -static inline int64 BIGMULS(int32 a, int32 b) { - return (int64)(a) * (int64)(b); -} /* OPT: optimized into an unsigned comparison */ //#define IS_INSIDE_1D(x, base, size) ((x) >= (base) && (x) < (base) + (size)) #define IS_INSIDE_1D(x, base, size) ( (uint)((x) - (base)) < ((uint)(size)) ) -template -static inline bool HASBIT(T x, int y) +template static inline bool HASBIT(T x, int y) { - return (x & (((T)1) << y)) != 0; + return (x & ((T)1 << y)) != 0; } -template -static inline T SETBIT(T& x, int y) +template static inline T SETBIT(T& x, int y) { - return x |= (((T)1) << y); + return x |= (T)1 << y; } -template -static inline T CLRBIT(T& x, int y) +template static inline T CLRBIT(T& x, int y) { - return x &= ~(((T)1) << y); + return x &= ~((T)1 << y); } -template -static inline T TOGGLEBIT(T& x, int y) +template static inline T TOGGLEBIT(T& x, int y) { - return x ^= (((T)1) << y); + return x ^= (T)1 << y; } @@ -154,11 +146,6 @@ #define abs myabs -static inline int intxchg_(int *a, int b) { int t = *a; *a = b; return t; } -#define intswap(a,b) ((b) = intxchg_(&(a), (b))) -static inline int uintxchg_(uint *a, uint b) { uint t = *a; *a = b; return t; } -#define uintswap(a,b) ((b) = uintxchg_(&(a), (b))) - static inline uint16 ReadLE16Aligned(const void* x) { @@ -189,8 +176,6 @@ #define ALIGN(x, n) (((x) + (n) - 1) & ~((n) - 1)) /** return the largest value that can be entered in a variable. - * known to work for uint32. - * used by TGP to set the max value of the _patches.generation_seed in its definition */ #define MAX_UVALUE(type) ((type)~(type)0) diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/misc.cpp --- a/src/misc.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/misc.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -16,8 +16,8 @@ #include "vehicle_gui.h" #include "variables.h" #include "ai/ai.h" -#include "table/landscape_const.h" #include "date.h" +#include "cargotype.h" char _name_array[512][32]; @@ -237,28 +237,11 @@ // Calculate constants that depend on the landscape type. void InitializeLandscapeVariables(bool only_constants) { - const CargoTypesValues *lpd; - uint i; - StringID str; - - lpd = &_cargo_types_base_values[_opt.landscape]; - - for (i = 0; i != NUM_CARGO; i++) { - _cargoc.sprites[i] = lpd->sprites[i]; + if (only_constants) return; - str = lpd->names[i]; - _cargoc.names_s[i] = str; - _cargoc.names_long[i] = (str += 0x40); - _cargoc.names_short[i] = (str += 0x20); - _cargoc.weights[i] = lpd->weights[i]; - - if (!only_constants) { - _cargo_payment_rates[i] = lpd->initial_cargo_payment[i]; - _cargo_payment_rates_frac[i] = 0; - } - - _cargoc.transit_days_1[i] = lpd->transit_days_table_1[i]; - _cargoc.transit_days_2[i] = lpd->transit_days_table_2[i]; + for (CargoID i = 0; i != NUM_CARGO; i++) { + _cargo_payment_rates[i] = GetCargo(i)->initial_payment; + _cargo_payment_rates_frac[i] = 0; } } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/misc_gui.cpp --- a/src/misc_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/misc_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -30,6 +30,7 @@ #include "tgp.h" #include "settings.h" #include "date.h" +#include "cargotype.h" #include "fios.h" /* Variables to display file lists */ @@ -153,10 +154,10 @@ /* If the accepted value is less than 8, show it in 1/8:ths */ if (ac[i] < 8) { SetDParam(0, ac[i]); - SetDParam(1, _cargoc.names_s[i]); + SetDParam(1, GetCargo(i)->name); p = GetString(p, STR_01D1_8, lastof(_landinfo_data[5])); } else { - p = GetString(p, _cargoc.names_s[i], lastof(_landinfo_data[5])); + p = GetString(p, GetCargo(i)->name, lastof(_landinfo_data[5])); } } } @@ -740,7 +741,7 @@ *b++ = ','; *b++ = ' '; } - b = InlineString(b, _cargoc.names_s[i]); + b = InlineString(b, GetCargo(i)->name); } } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/music/bemidi.h --- a/src/music/bemidi.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/music/bemidi.h Wed Feb 28 00:33:40 2007 +0000 @@ -7,4 +7,4 @@ extern const HalMusicDriver _bemidi_music_driver; -#endif +#endif /* MUSIC_BEMIDI_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/music/dmusic.cpp --- a/src/music/dmusic.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/music/dmusic.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,9 +1,8 @@ /* $Id$ */ -#include "../stdafx.h" - #ifdef WIN32_ENABLE_DIRECTMUSIC_SUPPORT +#include "../stdafx.h" #include "../debug.h" #include "../win32.h" #include "dmusic.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/music/extmidi.h --- a/src/music/extmidi.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/music/extmidi.h Wed Feb 28 00:33:40 2007 +0000 @@ -7,4 +7,4 @@ extern const HalMusicDriver _extmidi_music_driver; -#endif +#endif /* MUSIC_EXTERNAL_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/music/libtimidity.cpp --- a/src/music/libtimidity.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/music/libtimidity.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,4 +1,4 @@ -/* $Id: extmidi.c 4692 2006-05-02 19:09:49Z peter1138 $ */ +/* $Id$ */ #include "../stdafx.h" #include "../openttd.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/music/libtimidity.h --- a/src/music/libtimidity.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/music/libtimidity.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,4 +1,4 @@ -/* $Id: extmidi.h 2704 2005-07-25 07:16:10Z tron $ */ +/* $Id$ */ #ifndef MUSIC_LIBTIMIDITY_H #define MUSIC_LIBTIMIDITY_H diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/music/null_m.cpp --- a/src/music/null_m.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/music/null_m.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,7 +1,6 @@ /* $Id$ */ #include "../stdafx.h" -#include "../openttd.h" #include "null_m.h" static const char* NullMidiStart(const char* const* parm) { return NULL; } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/music/os2_m.h --- a/src/music/os2_m.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/music/os2_m.h Wed Feb 28 00:33:40 2007 +0000 @@ -7,4 +7,4 @@ extern const HalMusicDriver _os2_music_driver; -#endif +#endif /* MUSIC_OS2_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/music/qtmidi.cpp --- a/src/music/qtmidi.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/music/qtmidi.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,7 +1,7 @@ /* $Id$ */ /** - * @file qtmidi.c + * @file qtmidi.cpp * @brief MIDI music player for MacOS X using QuickTime. * * This music player should work in all MacOS X releases starting from 10.0, diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/music/qtmidi.h --- a/src/music/qtmidi.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/music/qtmidi.h Wed Feb 28 00:33:40 2007 +0000 @@ -7,4 +7,4 @@ extern const HalMusicDriver _qtime_music_driver; -#endif /* !MUSIC_MACOSX_QUICKTIME_H */ +#endif /* MUSIC_MACOSX_QUICKTIME_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/music/win32_m.cpp --- a/src/music/win32_m.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/music/win32_m.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,7 +1,6 @@ /* $Id$ */ #include "../stdafx.h" -#include "../openttd.h" #include "win32_m.h" #include #include @@ -50,7 +49,7 @@ char buf[512]; va_start(va, cmd); - vsprintf(buf, cmd, va); + vsnprintf(buf, lengthof(buf), cmd, va); va_end(va); return mciSendStringA(buf, NULL, 0, 0); } @@ -58,12 +57,9 @@ static bool MidiIntPlaySong(const char *filename) { MidiSendCommand("close all"); - if (MidiSendCommand("open \"%s\" type sequencer alias song", filename) != 0) - return false; + if (MidiSendCommand("open \"%s\" type sequencer alias song", filename) != 0) return false; - if (MidiSendCommand("play song from 0") != 0) - return false; - return true; + return MidiSendCommand("play song from 0") == 0; } static void MidiIntStopSong(void) @@ -104,9 +100,7 @@ s[0] = '\0'; // Delay somewhat in case we don't manage to play. - if (!_midi.playing) { - Sleep(5000); - } + if (!_midi.playing) Sleep(5000); } if (_midi.stop_song && _midi.playing) { @@ -115,8 +109,7 @@ MidiIntStopSong(); } - if (_midi.playing && !MidiIntIsSongPlaying()) - _midi.playing = false; + if (_midi.playing && !MidiIntIsSongPlaying()) _midi.playing = false; WaitForMultipleObjects(1, &_midi.wait_obj, FALSE, 1000); } while (!_midi.terminate); @@ -148,8 +141,7 @@ } } - if (CreateThread(NULL, 8192, MidiThread, 0, 0, &threadId) == NULL) - return "Failed to create thread"; + if (CreateThread(NULL, 8192, MidiThread, 0, 0, &threadId) == NULL) return "Failed to create thread"; return NULL; } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/music_gui.cpp --- a/src/music_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/music_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -422,12 +422,11 @@ case 5: // start playing msf.playing = true; break; - case 6:{ // volume sliders - byte *vol,new_vol; + case 6: { // volume sliders + byte *vol, new_vol; int x = e->we.click.pt.x - 88; - if (x < 0) - return; + if (x < 0) return; vol = &msf.music_vol; if (x >= 106) { @@ -435,7 +434,7 @@ x -= 106; } - new_vol = min(max(x-21,0)*2,127); + new_vol = min(max(x - 21, 0) * 2, 127); if (new_vol != *vol) { *vol = new_vol; if (vol == &msf.music_vol) diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/core/config.h --- a/src/network/core/config.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/core/config.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,14 +1,14 @@ /* $Id$ */ +/** + * @file config.h Configuration options of the network stuff + */ + #ifndef NETWORK_CORE_CONFIG_H #define NETWORK_CORE_CONFIG_H #ifdef ENABLE_NETWORK -/** - * @file config.h Configuration options of the network stuff - */ - /** DNS hostname of the masterserver */ #define NETWORK_MASTER_SERVER_HOST "master.openttd.org" /** Message sent to the masterserver to 'identify' this client as OpenTTD */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/core/core.cpp --- a/src/network/core/core.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/core/core.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,9 @@ /* $Id$ */ +/** + * @file core.cpp Functions used to initialize/shut down the core network + */ + #ifdef ENABLE_NETWORK #include "../../stdafx.h" @@ -8,10 +12,6 @@ #include "core.h" #include "packet.h" -/** - * @file core.cpp Functions used to initialize/shut down the core network - */ - #ifdef __MORPHOS__ /* the library base is required here */ struct Library *SocketBase = NULL; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/core/core.h --- a/src/network/core/core.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/core/core.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,9 @@ /* $Id$ */ +/** + * @file core.h Base for all network types (UDP and TCP) + */ + #ifndef NETWORK_CORE_H #define NETWORK_CORE_H @@ -8,10 +12,6 @@ #include "os_abstraction.h" #include "../../newgrf_config.h" -/** - * @file core.h Base for all network types (UDP and TCP) - */ - bool NetworkCoreInitialize(void); void NetworkCoreShutdown(void); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/core/game.h --- a/src/network/core/game.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/core/game.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,10 @@ /* $Id$ */ +/** + * @file game.h Information about a game that is sent between a + * game server, game client and masterserver. + */ + #ifndef NETWORK_CORE_GAME_H #define NETWORK_CORE_GAME_H @@ -10,11 +15,6 @@ #include "../../newgrf_config.h" /** - * @file game.h Information about a game that is sent between a - * game server, game client and masterserver. - */ - -/** * This is the struct used by both client and server * some fields will be empty on the client (like game_password) by default * and only filled with data a player enters. diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/core/os_abstraction.h --- a/src/network/core/os_abstraction.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/core/os_abstraction.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,14 +1,14 @@ /* $Id$ */ -#ifndef NETWORK_CORE_OS_ABSTRACTION_H -#define NETWORK_CORE_OS_ABSTRACTION_H - /** * @file os_abstraction.h Network stuff has many things that needs to be * included and/or implemented by default. * All those things are in this file. */ +#ifndef NETWORK_CORE_OS_ABSTRACTION_H +#define NETWORK_CORE_OS_ABSTRACTION_H + /* Include standard stuff per OS */ #ifdef ENABLE_NETWORK diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/core/packet.cpp --- a/src/network/core/packet.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/core/packet.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,9 @@ /* $Id$ */ +/** + * @file packet.cpp Basic functions to create, fill and read packets. + */ + #ifdef ENABLE_NETWORK #include "../../stdafx.h" @@ -9,10 +13,6 @@ #include "packet.h" -/** - * @file packet.cpp Basic functions to create, fill and read packets. - */ - /* Do not want to include functions.h and all required headers */ extern void NORETURN CDECL error(const char *str, ...); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/core/packet.h --- a/src/network/core/packet.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/core/packet.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,9 @@ /* $Id$ */ +/** + * @file packet.h Basic functions to create, fill and read packets. + */ + #ifndef NETWORK_CORE_PACKET_H #define NETWORK_CORE_PACKET_H @@ -8,10 +12,6 @@ #include "config.h" #include "core.h" -/** - * @file packet.h Basic functions to create, fill and read packets. - */ - typedef uint16 PacketSize; ///< Size of the whole packet. typedef uint8 PacketType; ///< Identifier for the packet diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/core/tcp.cpp --- a/src/network/core/tcp.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/core/tcp.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,9 @@ /* $Id$ */ +/** + * @file tcp.cpp Basic functions to receive and send TCP packets. + */ + #ifdef ENABLE_NETWORK #include "../../stdafx.h" @@ -14,10 +18,6 @@ #include "tcp.h" #include "../../helpers.hpp" -/** - * @file tcp.cpp Basic functions to receive and send TCP packets. - */ - /** Very ugly temporary hack !!! */ void NetworkTCPSocketHandler::Initialize() { diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/core/tcp.h --- a/src/network/core/tcp.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/core/tcp.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,9 @@ /* $Id$ */ +/** + * @file tcp.h Basic functions to receive and send TCP packets. + */ + #ifndef NETWORK_CORE_TCP_H #define NETWORK_CORE_TCP_H @@ -10,10 +14,6 @@ #include "packet.h" /** - * @file tcp.h Basic functions to receive and send TCP packets. - */ - -/** * Enum with all types of UDP packets. * The order of the first 4 packets MUST not be changed, as * it protects old clients from joining newer servers diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/core/udp.cpp --- a/src/network/core/udp.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/core/udp.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,9 @@ /* $Id$ */ +/** + * @file core/udp.cpp Basic functions to receive and send UDP packets. + */ + #ifdef ENABLE_NETWORK #include "../../stdafx.h" @@ -10,10 +14,6 @@ #include "udp.h" /** - * @file core/udp.cpp Basic functions to receive and send UDP packets. - */ - -/** * Start listening on the given host and port. * @param host the host (ip) to listen on * @param port the port to listen on diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/core/udp.h --- a/src/network/core/udp.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/core/udp.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,16 +1,5 @@ /* $Id$ */ -#ifndef NETWORK_CORE_UDP_H -#define NETWORK_CORE_UDP_H - -#ifdef ENABLE_NETWORK - -#include "os_abstraction.h" -#include "core.h" -#include "game.h" -#include "packet.h" -#include "../../debug.h" - /** * @file udp.h Basic functions to receive and send UDP packets. * @@ -72,6 +61,17 @@ * 1+ 1 whether the server is dedicated (0 = no, 1 = yes) */ +#ifndef NETWORK_CORE_UDP_H +#define NETWORK_CORE_UDP_H + +#ifdef ENABLE_NETWORK + +#include "os_abstraction.h" +#include "core.h" +#include "game.h" +#include "packet.h" +#include "../../debug.h" + /** Enum with all types of UDP packets. The order MUST not be changed **/ enum PacketUDPType { PACKET_UDP_CLIENT_FIND_SERVER, ///< Queries a game server for game information diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/network_gamelist.cpp --- a/src/network/network_gamelist.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/network_gamelist.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,10 @@ /* $Id$ */ +/** + * @file network_gamelist.cpp This file handles the GameList + * Also, it handles the request to a server for data about the server + */ + #ifdef ENABLE_NETWORK #include "../stdafx.h" @@ -11,11 +16,6 @@ #include "network_gamelist.h" #include "network_gui.h" -/** - * @file network_gamelist.cpp This file handles the GameList - * Also, it handles the request to a server for data about the server - */ - NetworkGameList *_network_game_list = NULL; /** Should we stop/contiue requerying of offline servers? */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/network/network_udp.cpp --- a/src/network/network_udp.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/network/network_udp.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,12 @@ /* $Id$ */ +/** + * @file network_udp.cpp This file handles the UDP related communication. + * + * This is the GameServer <-> MasterServer and GameServer <-> GameClient + * communication before the game is being joined. + */ + #ifdef ENABLE_NETWORK #include "../stdafx.h" @@ -15,13 +22,6 @@ #include "core/udp.h" -/** - * @file network_udp.c This file handles the UDP related communication. - * - * This is the GameServer <-> MasterServer and GameServer <-> GameClient - * communication before the game is being joined. - */ - enum { ADVERTISE_NORMAL_INTERVAL = 30000, // interval between advertising in ticks (15 minutes) ADVERTISE_RETRY_INTERVAL = 300, // readvertise when no response after this many ticks (9 seconds) diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/newgrf.cpp --- a/src/newgrf.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/newgrf.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -31,6 +31,7 @@ #include "newgrf_sound.h" #include "newgrf_spritegroup.h" #include "helpers.hpp" +#include "cargotype.h" /* TTDPatch extended GRF format codec * (c) Petr Baudis 2004 (GPL'd) @@ -67,6 +68,10 @@ /* Set if any vehicle is loaded which uses 2cc (two company colours) */ bool _have_2cc = false; +/* Default cargo translation table. By default there are 27 possible cargo types */ +static const uint _default_cargo_max = 27; +static CargoLabel _default_cargo_list[_default_cargo_max]; + typedef enum GrfDataType { GDT_SOUND, @@ -183,6 +188,24 @@ } } +static const char *grf_load_string(byte **buf, size_t max_len) +{ + const char *string = *(const char **)buf; + size_t string_length = ttd_strnlen(string, max_len); + + if (string_length == max_len) { + /* String was not NUL terminated, so make sure it is now. */ + (*buf)[string_length - 1] = '\0'; + grfmsg(7, "String was not terminated with a zero byte."); + } else { + /* Increase the string length to include the NUL byte. */ + string_length++; + } + *buf += string_length; + + return string; +} + static GRFFile *GetFileByGRFID(uint32 grfid) { GRFFile *file; @@ -345,7 +368,8 @@ if (ctype < NUM_CARGO) { rvi[i].cargo_type = ctype; } else { - grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, ignoring", ctype); + rvi[i].cargo_type = CT_INVALID; + grfmsg(2, "RailVehicleChangeInfo: Invalid cargo type %d, using first refittable", ctype); } } break; @@ -536,7 +560,8 @@ if (cargo < NUM_CARGO) { rvi[i].cargo_type = cargo; } else { - grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, ignoring", cargo); + rvi[i].cargo_type = CT_INVALID; + grfmsg(2, "RoadVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); } } break; @@ -646,17 +671,11 @@ FOR_EACH_OBJECT { uint8 cargo = grf_load_byte(&buf); - // XXX: Need to consult this with patchman yet. -#if 0 - // Documentation claims this is already the - // per-landscape cargo type id, but newships.grf - // assume otherwise. - cargo = local_cargo_id_ctype[cargo]; -#endif if (cargo < NUM_CARGO) { svi[i].cargo_type = cargo; } else { - grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, ignoring", cargo); + svi[i].cargo_type = CT_INVALID; + grfmsg(2, "ShipVehicleChangeInfo: Invalid cargo type %d, using first refittable", cargo); } } break; @@ -1174,6 +1193,12 @@ } break; + case 0x09: /* Cargo translation table */ + /* This is loaded during the initialisation stage, so just skip it here. */ + /* Each entry is 4 bytes. */ + buf += numinfo * 4; + break; + case 0x0A: // Currency display names FOR_EACH_OBJECT { uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); @@ -1258,7 +1283,6 @@ } break; - case 0x09: // Cargo translation table case 0x10: // 12 * 32 * B Snow line height table default: ret = true; @@ -1461,6 +1485,11 @@ uint8 numinfo; uint8 index; + if (len == 1) { + grfmsg(8, "Silently ignoring one-byte special sprite 0x00"); + return; + } + if (!check_length(len, 6, "SafeChangeInfo")) return; buf++; feature = grf_load_byte(&buf); @@ -1481,6 +1510,55 @@ _skip_sprites = -1; } +/* Action 0x00 (GLS_INIT) */ +static void InitChangeInfo(byte *buf, int len) +{ + byte *bufend = buf + len; + uint8 feature; + uint8 numprops; + uint8 numinfo; + uint8 index; + + if (len == 1) { + grfmsg(8, "Silently ignoring one-byte special sprite 0x00"); + return; + } + + if (!check_length(len, 6, "InitChangeInfo")) return; + buf++; + feature = grf_load_byte(&buf); + numprops = grf_load_byte(&buf); + numinfo = grf_load_byte(&buf); + index = grf_load_byte(&buf); + + while (numprops-- && buf < bufend) { + uint8 prop = grf_load_byte(&buf); + + switch (feature) { + case GSF_GLOBALVAR: + switch (prop) { + case 0x09: /* Cargo Translation Table */ + if (index != 0) { + grfmsg(1, "InitChangeInfo: Cargo translation table must start at zero"); + return; + } + + free(_cur_grffile->cargo_list); + _cur_grffile->cargo_max = numinfo; + _cur_grffile->cargo_list = MallocT(numinfo); + + int i; + FOR_EACH_OBJECT { + CargoLabel cl = grf_load_dword(&buf); + _cur_grffile->cargo_list[i] = BSWAP32(cl); + } + break; + } + break; + } + } +} + #undef FOR_EACH_OBJECT /** @@ -1814,6 +1892,35 @@ _cur_grffile->spritegroups[setid] = group; } +static CargoID TranslateCargo(uint8 feature, uint8 ctype) +{ + /* Special cargo types for purchase list and stations */ + if (feature == GSF_STATION && ctype == 0xFE) return CT_DEFAULT_NA; + if (ctype == 0xFF) return CT_PURCHASE; + + /* Check if the cargo type is out of bounds of the cargo translation table */ + if (ctype >= (_cur_grffile->cargo_max == 0 ? _default_cargo_max : _cur_grffile->cargo_max)) { + grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range (max %d), skipping.", ctype, (_cur_grffile->cargo_max == 0 ? _default_cargo_max : _cur_grffile->cargo_max) - 1); + return CT_INVALID; + } + + /* Look up the cargo label from the translation table */ + CargoLabel cl = _cur_grffile->cargo_max == 0 ? _default_cargo_list[ctype] : _cur_grffile->cargo_list[ctype]; + if (cl == 0) { + grfmsg(5, "FeatureMapSpriteGroup: Cargo type %d not available in this climate, skipping.", ctype); + return CT_INVALID; + } + + ctype = GetCargoIDByLabel(cl); + if (ctype == CT_INVALID) { + grfmsg(5, "FeatureMapSpriteGroup: Cargo '%c%c%c%c' unsupported, skipping.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8)); + return CT_INVALID; + } + + grfmsg(6, "FeatureMapSpriteGroup: Cargo '%c%c%c%c' mapped to cargo type %d.", GB(cl, 24, 8), GB(cl, 16, 8), GB(cl, 8, 8), GB(cl, 0, 8), ctype); + return ctype; +} + /* Action 0x03 */ static void FeatureMapSpriteGroup(byte *buf, int len) { @@ -1885,13 +1992,8 @@ return; } - if (ctype == 0xFE) ctype = GC_DEFAULT_NA; - if (ctype == 0xFF) ctype = GC_PURCHASE; - - if (ctype >= NUM_GLOBAL_CID) { - grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); - continue; - } + ctype = TranslateCargo(feature, ctype); + if (ctype == CT_INVALID) continue; statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid]; } @@ -1911,7 +2013,7 @@ uint8 stid = buf[3 + i]; StationSpec *statspec = _cur_grffile->stations[stid]; - statspec->spritegroup[GC_DEFAULT] = _cur_grffile->spritegroups[groupid]; + statspec->spritegroup[CT_DEFAULT] = _cur_grffile->spritegroups[groupid]; statspec->grfid = _cur_grffile->grfid; statspec->localidx = stid; SetCustomStationSpec(statspec); @@ -1967,12 +2069,8 @@ return; } - if (ctype == GC_INVALID) ctype = GC_PURCHASE; - - if (ctype >= NUM_GLOBAL_CID) { - grfmsg(1, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); - continue; - } + ctype = TranslateCargo(feature, ctype); + if (ctype == CT_INVALID) continue; if (wagover) { SetWagonOverrideSprites(engine, ctype, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); @@ -2005,10 +2103,10 @@ SetRotorOverrideSprites(engine, _cur_grffile->spritegroups[groupid]); } else { // TODO: No multiple cargo types per vehicle yet. --pasky - SetWagonOverrideSprites(engine, GC_DEFAULT, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); + SetWagonOverrideSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); } } else { - SetCustomEngineSprites(engine, GC_DEFAULT, _cur_grffile->spritegroups[groupid]); + SetCustomEngineSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid]); SetEngineGRF(engine, _cur_grffile); last_engines[i] = engine; } @@ -2046,7 +2144,6 @@ uint8 num; uint16 id; uint16 endid; - const char* name; bool new_scheme = _cur_grffile->grf_version >= 7; bool generic; @@ -2068,13 +2165,19 @@ grfmsg(6, "FeatureNewName: About to rename engines %d..%d (feature %d) in language 0x%02X", id, endid, feature, lang); - name = (const char*)buf; /*transfer read value*/ len -= generic ? 6 : 5; for (; id < endid && len > 0; id++) { - size_t ofs = strlen(name) + 1; - - if (ofs < 128) { + const char *name = grf_load_string(&buf, len); + size_t name_length = strlen(name) + 1; + + len -= (int)name_length; + + if (name_length == 1) { + grfmsg(7, "FeatureNewName: Can't add empty name"); + } else if (name_length > 127) { + grfmsg(7, "FeatureNewName: Too long a name (%d)", name_length); + } else { grfmsg(8, "FeatureNewName: %d <- %s", id, name); switch (feature) { @@ -2143,17 +2246,7 @@ break; #endif } - } else { - /* ofs is the string length + 1, so if the string is empty, ofs - * is 1 */ - if (ofs == 1) { - grfmsg(7, "FeatureNewName: Can't add empty name"); - } else { - grfmsg(7, "FeatureNewName: Too long a name (%d)", ofs); - } } - name += ofs; - len -= (int)ofs; } } @@ -2521,6 +2614,9 @@ * we use -1 to indicate that all further * sprites should be skipped. */ _skip_sprites = -1; + + /* If an action 8 hasn't been encountered yet, disable the grf. */ + if (!HASBIT(_cur_grfconfig->flags, GCF_ACTIVATED)) SETBIT(_cur_grfconfig->flags, GCF_DISABLED); } } @@ -2579,7 +2675,7 @@ if (!check_length(len, 8, "GRFInfo")) return; buf++; version = grf_load_byte(&buf); grfid = grf_load_dword(&buf); - name = (const char*)buf; + name = grf_load_string(&buf, len - 6); _cur_grffile->grfid = grfid; _cur_grffile->grf_version = version; @@ -2622,7 +2718,7 @@ } /* Action 0x0B */ -static void GRFError(byte *buf, int len) +static void GRFLoadError(byte *buf, int len) { /* <0B> [ 00] [] 00 [] * @@ -2637,40 +2733,105 @@ * S message for custom messages (message-id FF), text of the message * not present for built-in messages. * V data additional data for built-in (or custom) messages - * B parnum see action 6, only used with built-in message 03 */ - /* TODO: For now we just show the message, sometimes incomplete and never translated. */ - - static const char *const msgstr[] = { - "%sRequires at least pseudo-TTDPatch version %s", - "%sThis file is for %s version of TTD", - "%sDesigned to be used with %s", - "%sInvalid parameter %s", - "%sMust be loaded before %s", - "%sMust be loaded after %s", - "%s%s" + * B parnum parameter numbers to be shown in the message (maximum of 2) */ + + static const StringID msgstr[] = { + STR_NEWGRF_ERROR_VERSION_NUMBER, + STR_NEWGRF_ERROR_DOS_OR_WINDOWS, + STR_NEWGRF_ERROR_UNSET_SWITCH, + STR_NEWGRF_ERROR_INVALID_PARAMETER, + STR_NEWGRF_ERROR_LOAD_BEFORE, + STR_NEWGRF_ERROR_LOAD_AFTER }; - static const char *const sevstr[] = { - "", - "Warning: ", - "Error: ", - "Fatal: ", + static const StringID sevstr[] = { + STR_NEWGRF_ERROR_MSG_INFO, + STR_NEWGRF_ERROR_MSG_WARNING, + STR_NEWGRF_ERROR_MSG_ERROR, + STR_NEWGRF_ERROR_MSG_FATAL }; - uint8 sevid; - uint8 msgid; - - if (!check_length(len, 6, "GRFError")) return; - sevid = buf[1]; - msgid = buf[3]; - - // Undocumented TTDPatch feature. - if (!HASBIT(sevid, 7) && _cur_stage < GLS_ACTIVATION) { - grfmsg(7, "Skipping non-fatal GRFError in stage 1"); + + /* AddGRFString expects the string to be referred to by an id in the newgrf + * file. Errors messages are never referred to however, so invent ids that + * are unlikely to be reached in a newgrf file so they don't overwrite + * anything else. */ + enum { + MESSAGE_STRING_ID = MAX_UVALUE(StringID) - 1, + MESSAGE_DATA_ID = MAX_UVALUE(StringID) + }; + + if (!check_length(len, 6, "GRFLoadError")) return; + + /* For now we can only show one message per newgrf file. */ + if (_cur_grfconfig->error != NULL) return; + + buf++; /* Skip the action byte. */ + byte severity = grf_load_byte(&buf); + byte lang = grf_load_byte(&buf); + byte message_id = grf_load_byte(&buf); + len -= 4; + + /* Skip the error until the activation stage unless bit 7 of the severity + * is set. */ + if (!HASBIT(severity, 7) && _cur_stage < GLS_ACTIVATION) { + grfmsg(7, "Skipping non-fatal GRFLoadError in stage 1"); return; } - - sevid = GB(sevid, 0, 2); - grfmsg(0, msgstr[(msgid == 0xFF) ? lengthof(msgstr) - 1 : msgid], sevstr[sevid], &buf[4]); + CLRBIT(severity, 7); + + if (severity >= lengthof(sevstr)) { + grfmsg(7, "GRFLoadError: Invalid severity id %d. Setting to 2 (non-fatal error).", severity); + severity = 2; + } else if (severity == 3) { + /* This is a fatal error, so make sure the GRF is deactivated and no + * more of it gets loaded. */ + SETBIT(_cur_grfconfig->flags, GCF_DISABLED); + CLRBIT(_cur_grfconfig->flags, GCF_ACTIVATED); + + _skip_sprites = -1; + } + + if (message_id >= lengthof(msgstr) && message_id != 0xFF) { + grfmsg(7, "GRFLoadError: Invalid message id."); + return; + } + + if (len <= 1) { + grfmsg(7, "GRFLoadError: No message data supplied."); + return; + } + + bool new_scheme = _cur_grffile->grf_version >= 7; + GRFError *error = CallocT(1); + + error->severity = sevstr[severity]; + + if (message_id == 0xFF) { + /* This is a custom error message. */ + const char *message = grf_load_string(&buf, len); + len -= (strlen(message) + 1); + + error->message = AddGRFString(_cur_grffile->grfid, MESSAGE_STRING_ID, lang, new_scheme, message, STR_UNDEFINED); + } else { + error->message = msgstr[message_id]; + } + + if (len > 0) { + const char *data = grf_load_string(&buf, len); + len -= (strlen(data) + 1); + + error->data = AddGRFString(_cur_grffile->grfid, MESSAGE_DATA_ID, lang, new_scheme, data, STR_UNDEFINED); + } + + /* Only two parameter numbers can be used in the string. */ + uint i = 0; + for (; i < 2 && len > 0; i++) { + error->param_number[i] = grf_load_byte(&buf); + len--; + } + error->num_params = i; + + _cur_grfconfig->error = error; } /* Action 0x0C */ @@ -2680,11 +2841,11 @@ * * V ignored Anything following the 0C is ignored */ - static char comment[256]; if (len == 1) return; - ttd_strlcpy(comment, (char*)(buf + 1), minu(sizeof(comment), len)); - grfmsg(2, "GRFComment: %s", comment); + int text_len = len - 1; + const char *text = (const char*)(buf + 1); + grfmsg(2, "GRFComment: %.*s", text_len, text); } /* Action 0x0D (GLS_SAFETYSCAN) */ @@ -3503,6 +3664,16 @@ // Add engine type to engine data. This is needed for the refit precalculation. AddTypeToEngines(); + /* Set up the default cargo types */ + SetupCargoForClimate(_opt.landscape); + + /* Generate default cargo translation table */ + memset(_default_cargo_list, 0, sizeof(_default_cargo_list)); + for (CargoID c = 0; c != NUM_CARGO; c++) { + const CargoSpec *cs = GetCargo(c); + if (cs->IsValid()) _default_cargo_list[cs->bitnum] = cs->label; + } + /* Reset misc GRF features and train list display variables */ _misc_grf_features = 0; _traininfo_vehicle_pitch = 0; @@ -3533,6 +3704,29 @@ _cur_grffile->spritegroups_count = 0; } +static void BuildCargoTranslationMap() +{ + memset(_cur_grffile->cargo_map, 0xFF, sizeof(_cur_grffile->cargo_map)); + + for (CargoID c = 0; c < NUM_CARGO; c++) { + const CargoSpec *cs = GetCargo(c); + if (!cs->IsValid()) continue; + + if (_cur_grffile->cargo_max == 0) { + /* Default translation table, so just a straight mapping to bitnum */ + _cur_grffile->cargo_map[c] = cs->bitnum; + } else { + /* Check the translation table for this cargo's label */ + for (uint i = 0; i < _cur_grffile->cargo_max; i++) { + if (cs->label == _cur_grffile->cargo_list[i]) { + _cur_grffile->cargo_map[c] = i; + break; + } + } + } + } +} + static void InitNewGRFFile(const GRFConfig *config, int sprite_offset) { GRFFile *newfile; @@ -3567,28 +3761,36 @@ } -/** Bitmasked values of what type of cargo is refittable for the given vehicle-type. - * This coupled with the landscape information (_landscape_global_cargo_mask) gives - * us exactly what is refittable and what is not */ -#define MC(cargo) (1 << cargo) -static const uint32 _default_refitmasks[NUM_VEHICLE_TYPES] = { - /* Trains */ - MC(GC_PASSENGERS) | MC(GC_COAL) | MC(GC_MAIL) | MC(GC_LIVESTOCK) | MC(GC_GOODS) | MC(GC_GRAIN) | MC(GC_WOOD) | MC(GC_IRON_ORE) | - MC(GC_STEEL) | MC(GC_VALUABLES) | MC(GC_PAPER) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_COPPER_ORE) | MC(GC_WATER) | MC(GC_SUGAR) | - MC(GC_TOYS) | MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS), - /* Road vehicles (not refittable by default) */ - 0, - /* Ships */ - MC(GC_COAL) | MC(GC_MAIL) | MC(GC_LIVESTOCK) | MC(GC_GOODS) | MC(GC_GRAIN) | MC(GC_WOOD) | MC(GC_IRON_ORE) | MC(GC_STEEL) | MC(GC_VALUABLES) | - MC(GC_PAPER) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_COPPER_ORE) | MC(GC_WATER) | MC(GC_RUBBER) | MC(GC_SUGAR) | MC(GC_TOYS) | MC(GC_BATTERIES) | - MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS), - /* Aircraft */ - MC(GC_PASSENGERS) | MC(GC_MAIL) | MC(GC_GOODS) | MC(GC_VALUABLES) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_SUGAR) | MC(GC_TOYS) | - MC(GC_BATTERIES) | MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS), - /* Special/Disaster */ - 0,0 +/** List of what cargo labels are refittable for the given the vehicle-type. + * Only currently active labels are applied. */ +static const CargoLabel _default_refitmasks_rail[] = { + 'PASS', 'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', + 'IORE', 'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', + 'WATR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', + 'PLST', 'FZDR', + 0 }; + +static const CargoLabel _default_refitmasks_road[] = { + 0 }; + +static const CargoLabel _default_refitmasks_ships[] = { + 'COAL', 'MAIL', 'LVST', 'GOOD', 'GRAI', 'WHEA', 'MAIZ', 'WOOD', 'IORE', + 'STEL', 'VALU', 'GOLD', 'DIAM', 'PAPR', 'FOOD', 'FRUT', 'CORE', 'WATR', + 'RUBR', 'SUGR', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', + 'PLST', 'FZDR', + 0 }; + +static const CargoLabel _default_refitmasks_aircraft[] = { + 'PASS', 'MAIL', 'GOOD', 'VALU', 'GOLD', 'DIAM', 'FOOD', 'FRUT', 'SUGR', + 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', 'PLST', 'FZDR', + 0 }; + +static const CargoLabel *_default_refitmasks[] = { + _default_refitmasks_rail, + _default_refitmasks_road, + _default_refitmasks_ships, + _default_refitmasks_aircraft, }; -#undef MC /** @@ -3606,9 +3808,10 @@ if (cargo_allowed[engine] != 0) { // Build up the list of cargo types from the set cargo classes. - for (i = 0; i < lengthof(cargo_classes); i++) { - if (HASBIT(cargo_allowed[engine], i)) mask |= cargo_classes[i]; - if (HASBIT(cargo_disallowed[engine], i)) not_mask |= cargo_classes[i]; + for (i = 0; i < NUM_CARGO; i++) { + const CargoSpec *cs = GetCargo(i); + if (cargo_allowed[engine] & cs->classes) SETBIT(mask, i); + if (cargo_disallowed[engine] & cs->classes) SETBIT(not_mask, i); } } else { // Don't apply default refit mask to wagons or engines with no capacity @@ -3618,10 +3821,40 @@ RailVehInfo(engine)->railveh_type != RAILVEH_WAGON ) )) { - xor_mask = _default_refitmasks[GetEngine(engine)->type]; + const CargoLabel *cl = _default_refitmasks[GetEngine(engine)->type]; + for (uint i = 0;; i++) { + if (cl[i] == 0) break; + + CargoID cargo = GetCargoIDByLabel(cl[i]); + if (cargo == CT_INVALID) continue; + + SETBIT(xor_mask, cargo); + } } } - _engine_info[engine].refit_mask = ((mask & ~not_mask) ^ xor_mask) & _landscape_global_cargo_mask[_opt.landscape]; + _engine_info[engine].refit_mask = ((mask & ~not_mask) ^ xor_mask) & _cargo_mask; + + if (_engine_info[engine].refit_mask == 0) continue; + + /* Check if this engine's cargo type is valid. If not, set to the first refittable + * cargo type. Apparently cargo_type isn't a common property... */ + switch (GetEngine(engine)->type) { + case VEH_Train: { + RailVehicleInfo *rvi = &_rail_vehicle_info[engine]; + if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine); + break; + } + case VEH_Road: { + RoadVehicleInfo *rvi = &_road_vehicle_info[engine - ROAD_ENGINES_INDEX]; + if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine); + break; + } + case VEH_Ship: { + ShipVehicleInfo *svi = &_ship_vehicle_info[engine - SHIP_ENGINES_INDEX]; + if (svi->cargo_type == CT_INVALID) svi->cargo_type = FindFirstRefittableCargo(engine); + break; + } + } } } @@ -3646,7 +3879,7 @@ * is not in memory and scanning the file every time would be too expensive. * In other stages we skip action 0x10 since it's already dealt with. */ static const SpecialSpriteHandler handlers[][GLS_END] = { - /* 0x00 */ { NULL, SafeChangeInfo, NULL, NULL, FeatureChangeInfo, }, + /* 0x00 */ { NULL, SafeChangeInfo, NULL, InitChangeInfo, FeatureChangeInfo, }, /* 0x01 */ { NULL, GRFUnsafe, NULL, NULL, NewSpriteSet, }, /* 0x02 */ { NULL, GRFUnsafe, NULL, NULL, NewSpriteGroup, }, /* 0x03 */ { NULL, GRFUnsafe, NULL, NULL, FeatureMapSpriteGroup, }, @@ -3657,7 +3890,7 @@ /* 0x08 */ { ScanInfo, NULL, NULL, GRFInfo, GRFInfo, }, /* 0x09 */ { NULL, NULL, NULL, SkipIf, SkipIf, }, /* 0x0A */ { NULL, NULL, NULL, NULL, SpriteReplace, }, - /* 0x0B */ { NULL, NULL, NULL, GRFError, GRFError, }, + /* 0x0B */ { NULL, NULL, NULL, GRFLoadError, GRFLoadError, }, /* 0x0C */ { NULL, NULL, NULL, GRFComment, GRFComment, }, /* 0x0D */ { NULL, SafeParamSet, NULL, ParamSet, ParamSet, }, /* 0x0E */ { NULL, SafeGRFInhibit, NULL, GRFInhibit, GRFInhibit, }, @@ -3726,6 +3959,8 @@ if (stage == GLS_ACTIVATION && !HASBIT(config->flags, GCF_ACTIVATED)) return; } + if (stage == GLS_ACTIVATION) CLRBIT(config->flags, GCF_ACTIVATED); + FioOpenFile(file_index, filename); _file_index = file_index; // XXX @@ -3817,6 +4052,7 @@ LoadNewGRFFile(c, slot++, stage); if (stage == GLS_ACTIVATION) { ClearTemporaryNewGRFData(); + BuildCargoTranslationMap(); DEBUG(sprite, 2, "Currently %i sprites are loaded", _cur_spriteid); } } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/newgrf.h --- a/src/newgrf.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/newgrf.h Wed Feb 28 00:33:40 2007 +0000 @@ -6,6 +6,7 @@ #include "station.h" #include "newgrf_config.h" #include "helpers.hpp" +#include "cargotype.h" typedef enum GrfLoadingStage { GLS_FILESCAN, @@ -60,6 +61,10 @@ uint param_end; /// one more than the highest set parameter GRFLabel *label; ///< Pointer to the first label. This is a linked list, not an array. + + uint8 cargo_max; + CargoLabel *cargo_list; + uint8 cargo_map[NUM_CARGO]; } GRFFile; extern GRFFile *_first_grffile; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/newgrf_cargo.cpp --- a/src/newgrf_cargo.cpp Tue Feb 27 23:54:28 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* $Id$ */ - -#include "stdafx.h" -#include "openttd.h" -#include "newgrf_cargo.h" - -/** TRANSLATE FROM LOCAL CARGO TO GLOBAL CARGO ID'S. - * This maps the per-landscape cargo ID's to globally unique cargo ID's usable ie. in - * the custom GRF files. It is basically just a transcribed table from TTDPatch's newgrf.txt. - */ -const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO] = { - /* LT_NORMAL */ {GC_PASSENGERS, GC_COAL, GC_MAIL, GC_OIL, GC_LIVESTOCK, GC_GOODS, GC_GRAIN, GC_WOOD, GC_IRON_ORE, GC_STEEL, GC_VALUABLES, GC_PAPER_TEMP}, - /* LT_HILLY */ {GC_PASSENGERS, GC_COAL, GC_MAIL, GC_OIL, GC_LIVESTOCK, GC_GOODS, GC_GRAIN, GC_WOOD, GC_INVALID, GC_PAPER, GC_VALUABLES, GC_FOOD }, - /* LT_DESERT */ {GC_PASSENGERS, GC_RUBBER, GC_MAIL, GC_OIL, GC_FRUIT, GC_GOODS, GC_GRAIN, GC_WOOD, GC_COPPER_ORE, GC_WATER, GC_VALUABLES, GC_FOOD }, - /* LT_CANDY */ {GC_PASSENGERS, GC_SUGAR, GC_MAIL, GC_TOYS, GC_BATTERIES, GC_CANDY, GC_TOFFEE, GC_COLA, GC_COTTON_CANDY, GC_BUBBLES, GC_PLASTIC, GC_FIZZY_DRINKS }, - /** - * - GC_INVALID (255) means that cargo is not available for that climate - * - GC_PAPER_TEMP (27) is paper in temperate climate in TTDPatch - * Following can be renumbered: - * - GC_DEFAULT (29) is the defa ult cargo for the purpose of spritesets - * - GC_PURCHASE (30) is the purchase list image (the equivalent of 0xff) for the purpose of spritesets - */ -}; - -/** BEGIN --- TRANSLATE FROM GLOBAL CARGO TO LOCAL CARGO ID'S **/ -/** Map global cargo ID's to local-cargo ID's */ -const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID] = { - CT_PASSENGERS, CT_COAL, CT_MAIL, CT_OIL, CT_LIVESTOCK, CT_GOODS, CT_GRAIN, CT_WOOD, /* 0- 7 */ - CT_IRON_ORE, CT_STEEL, CT_VALUABLES, CT_PAPER, CT_FOOD, CT_FRUIT, CT_COPPER_ORE, CT_WATER, /* 8-15 */ - CT_RUBBER, CT_SUGAR, CT_TOYS, CT_BATTERIES, CT_CANDY, CT_TOFFEE, CT_COLA, CT_COTTON_CANDY, /* 16-23 */ - CT_BUBBLES, CT_PLASTIC, CT_FIZZY_DRINKS, CT_PAPER /* unsup. */, CT_HILLY_UNUSED, /* 24-28 */ - CT_INVALID, CT_INVALID /* 29-30 */ -}; - -/** Bitmasked value where the global cargo ID is available in landscape - * 0: LT_NORMAL, 1: LT_HILLY, 2: LT_DESERT, 3: LT_CANDY */ -#define MC(cargo) (1 << cargo) -const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE] = -{ /* LT_NORMAL: temperate */ - MC(GC_PASSENGERS) | MC(GC_COAL) | MC(GC_MAIL) | MC(GC_OIL) | MC(GC_LIVESTOCK) | MC(GC_GOODS) | MC(GC_GRAIN) | MC(GC_WOOD) | MC(GC_IRON_ORE) | MC(GC_STEEL) | MC(GC_VALUABLES), - /* LT_HILLY: arctic */ - MC(GC_PASSENGERS) | MC(GC_COAL) | MC(GC_MAIL) | MC(GC_OIL) | MC(GC_LIVESTOCK) | MC(GC_GOODS) | MC(GC_GRAIN) | MC(GC_WOOD) | MC(GC_VALUABLES) | MC(GC_PAPER) | MC(GC_FOOD), - /* LT_DESERT: rainforest/desert */ - MC(GC_PASSENGERS) | MC(GC_MAIL) | MC(GC_OIL) | MC(GC_GOODS) | MC(GC_GRAIN) | MC(GC_WOOD) | MC(GC_VALUABLES) | MC(GC_FOOD) | MC(GC_FRUIT) | MC(GC_COPPER_ORE) | MC(GC_WATER) | MC(GC_RUBBER), - /* LT_CANDY: toyland */ - MC(GC_PASSENGERS) | MC(GC_MAIL) | MC(GC_SUGAR) | MC(GC_TOYS) | MC(GC_BATTERIES) | MC(GC_CANDY) | MC(GC_TOFFEE) | MC(GC_COLA) | MC(GC_COTTON_CANDY) | MC(GC_BUBBLES) | MC(GC_PLASTIC) | MC(GC_FIZZY_DRINKS) -}; -/** END --- TRANSLATE FROM GLOBAL CARGO TO LOCAL CARGO ID'S **/ - -/** - * Bitmask of classes for cargo types. - */ -const uint32 cargo_classes[16] = { - /* Passengers */ MC(GC_PASSENGERS), - /* Mail */ MC(GC_MAIL), - /* Express */ MC(GC_GOODS) | MC(GC_FOOD) | MC(GC_CANDY), - /* Armoured */ MC(GC_VALUABLES), - /* Bulk */ MC(GC_COAL) | MC(GC_GRAIN) | MC(GC_IRON_ORE) | MC(GC_COPPER_ORE) | MC(GC_FRUIT) | MC(GC_SUGAR) | MC(GC_TOFFEE) | MC(GC_COTTON_CANDY), - /* Piece */ MC(GC_LIVESTOCK) | MC(GC_WOOD) | MC(GC_STEEL) | MC(GC_PAPER) | MC(GC_TOYS) | MC(GC_BATTERIES) | MC(GC_BUBBLES) | MC(GC_FIZZY_DRINKS), - /* Liquids */ MC(GC_OIL) | MC(GC_WATER) | MC(GC_RUBBER) | MC(GC_COLA) | MC(GC_PLASTIC), - /* Chilled */ MC(GC_FOOD) | MC(GC_FRUIT), - /* Undefined */ 0, 0, 0, 0, 0, 0, 0, 0 -}; -#undef MC - -/** - *there are 32 slots available per climate with newcargo.*/ -#define MAXSLOTS 32 diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/newgrf_cargo.h --- a/src/newgrf_cargo.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/newgrf_cargo.h Wed Feb 28 00:33:40 2007 +0000 @@ -15,46 +15,8 @@ CC_REFRIGERATED = 1 << 7, }; -enum GlobalCargo { - GC_PASSENGERS = 0, - GC_COAL = 1, - GC_MAIL = 2, - GC_OIL = 3, - GC_LIVESTOCK = 4, - GC_GOODS = 5, - GC_GRAIN = 6, // GC_WHEAT / GC_MAIZE - GC_WOOD = 7, - GC_IRON_ORE = 8, - GC_STEEL = 9, - GC_VALUABLES = 10, // GC_GOLD / GC_DIAMONDS - GC_PAPER = 11, - GC_FOOD = 12, - GC_FRUIT = 13, - GC_COPPER_ORE = 14, - GC_WATER = 15, - GC_RUBBER = 16, - GC_SUGAR = 17, - GC_TOYS = 18, - GC_BATTERIES = 19, - GC_CANDY = 20, - GC_TOFFEE = 21, - GC_COLA = 22, - GC_COTTON_CANDY = 23, - GC_BUBBLES = 24, - GC_PLASTIC = 25, - GC_FIZZY_DRINKS = 26, - GC_PAPER_TEMP = 27, - GC_UNDEFINED = 28, // undefined; unused slot in arctic climate - GC_DEFAULT = 29, - GC_PURCHASE = 30, - GC_DEFAULT_NA = 31, // New stations only - GC_INVALID = 255, - NUM_GLOBAL_CID = 32 -}; - -extern const CargoID _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO]; -extern const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE]; -extern const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID]; -extern const uint32 cargo_classes[16]; +static const CargoID CT_DEFAULT = NUM_CARGO + 0; +static const CargoID CT_PURCHASE = NUM_CARGO + 1; +static const CargoID CT_DEFAULT_NA = NUM_CARGO + 2; #endif /* NEWGRF_CARGO_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/newgrf_config.cpp --- a/src/newgrf_config.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/newgrf_config.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -16,14 +16,10 @@ #include "fileio.h" #include "fios.h" -#include #include #ifdef WIN32 # include -#else -# include -# include #endif /* WIN32 */ @@ -95,6 +91,7 @@ free((*config)->filename); free((*config)->name); free((*config)->info); + free((*config)->error); } free(*config); *config = NULL; @@ -115,7 +112,7 @@ /** Copy a GRF Config list * @param dst pointer to destination list - * @param srt pointer to source list values + * @param src pointer to source list values * @return pointer to the last value added to the destination list */ GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src) { @@ -127,6 +124,10 @@ if (src->filename != NULL) c->filename = strdup(src->filename); if (src->name != NULL) c->name = strdup(src->name); if (src->info != NULL) c->info = strdup(src->info); + if (src->error != NULL) { + c->error = CallocT(1); + memcpy(c->error, src->error, sizeof(GRFError)); + } *dst = c; dst = &c->next; @@ -179,6 +180,17 @@ RemoveDuplicatesFromGRFConfigList(*dst); } +/** Appends an element to a list of GRFs + * @param dst the head of the list to add to */ +void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el) +{ + GRFConfig **tail = dst; + while (*tail != NULL) tail = &(*tail)->next; + *tail = el; + + RemoveDuplicatesFromGRFConfigList(*dst); +} + /* Reset the current GRF Config to either blank or newgame settings */ void ResetGRFConfig(bool defaults) @@ -245,6 +257,7 @@ memcpy(c->md5sum, f->md5sum, sizeof(c->md5sum)); if (c->name == NULL) c->name = strdup(f->name); if (c->info == NULL) c->info = strdup(f->info); + c->error = NULL; } } } @@ -263,7 +276,7 @@ struct dirent *dirent; DIR *dir; - if ((dir = opendir(path)) == NULL) return 0; + if ((dir = ttd_opendir(path)) == NULL) return 0; while ((dirent = readdir(dir)) != NULL) { const char *d_name = FS2OTTD(dirent->d_name); @@ -441,10 +454,9 @@ static void Save_NGRF(void) { - GRFConfig *c; int index = 0; - for (c = _grfconfig; c != NULL; c = c->next) { + for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { if (HASBIT(c->flags, GCF_STATIC)) continue; SlSetArrayIndex(index++); SlObject(c, _grfconfig_desc); @@ -454,23 +466,14 @@ static void Load_NGRF(void) { - GRFConfig *first = NULL; - GRFConfig **last = &first; - + ClearGRFConfigList(&_grfconfig); while (SlIterateArray() != -1) { GRFConfig *c = CallocT(1); SlObject(c, _grfconfig_desc); - - /* Append our configuration to the list */ - *last = c; - last = &c->next; + AppendToGRFConfigList(&_grfconfig, c); } /* Append static NewGRF configuration */ - CopyGRFConfigList(last, _grfconfig_static); - - ClearGRFConfigList(&_grfconfig); - _grfconfig = first; AppendStaticGRFConfigs(&_grfconfig); } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/newgrf_config.h --- a/src/newgrf_config.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/newgrf_config.h Wed Feb 28 00:33:40 2007 +0000 @@ -3,6 +3,8 @@ #ifndef NEWGRF_CONFIG_H #define NEWGRF_CONFIG_H +#include "openttd.h" + /* GRF config bit flags */ typedef enum { GCF_DISABLED, ///< GRF file is disabled @@ -20,10 +22,19 @@ uint8 md5sum[16]; } GRF; +typedef struct GRFError { + StringID message; + StringID data; + StringID severity; + uint8 num_params; + uint8 param_number[2]; +} GRFError; + typedef struct GRFConfig : public GRFIdentifier { char *filename; char *name; char *info; + GRFError *error; uint8 flags; uint32 param[0x80]; @@ -49,6 +60,7 @@ GRFConfig *GetGRFConfig(uint32 grfid); GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src); void AppendStaticGRFConfigs(GRFConfig **dst); +void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el); void ClearGRFConfig(GRFConfig **config); void ClearGRFConfigList(GRFConfig **config); void ResetGRFConfig(bool defaults); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/newgrf_engine.cpp --- a/src/newgrf_engine.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/newgrf_engine.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -18,43 +18,8 @@ #include "newgrf_cargo.h" #include "date.h" #include "helpers.hpp" - - +#include "cargotype.h" -/* Default cargo classes */ -static const uint16 _cargo_classes[NUM_GLOBAL_CID] = { - CC_PASSENGERS, - CC_BULK, - CC_MAIL, - CC_LIQUID, - CC_PIECE_GOODS, - CC_EXPRESS, - CC_BULK, - CC_PIECE_GOODS, - CC_BULK, - CC_PIECE_GOODS, - CC_ARMOURED, - CC_PIECE_GOODS, - CC_REFRIGERATED | CC_EXPRESS, - CC_REFRIGERATED | CC_EXPRESS, - CC_BULK, - CC_LIQUID, - CC_LIQUID, - CC_BULK, - CC_PIECE_GOODS, - CC_PIECE_GOODS, - CC_EXPRESS, - CC_BULK, - CC_LIQUID, - CC_BULK, - CC_PIECE_GOODS, - CC_LIQUID, - CC_PIECE_GOODS, - CC_PIECE_GOODS, - CC_NOAVAILABLE, - CC_NOAVAILABLE, - CC_NOAVAILABLE, -}; int _traininfo_vehicle_pitch = 0; int _traininfo_vehicle_width = 29; @@ -79,7 +44,7 @@ WagonOverride *wo; assert(engine < TOTAL_NUM_ENGINES); - assert(cargo < NUM_GLOBAL_CID); + assert(cargo < NUM_CARGO + 1); // Include CT_DEFAULT pseudo cargo. CT_PURCHASE does not apply to overrides. wos = &_engine_wagon_overrides[engine]; wos->overrides_count++; @@ -111,7 +76,7 @@ int j; for (j = 0; j < wo->trains; j++) { - if (wo->train_id[j] == overriding_engine && (wo->cargo == cargo || wo->cargo == GC_DEFAULT)) return wo->group; + if (wo->train_id[j] == overriding_engine && (wo->cargo == cargo || wo->cargo == CT_DEFAULT)) return wo->group; } } return NULL; @@ -140,22 +105,19 @@ } } -// 0 - 28 are cargos, 29 is default, 30 is the advert (purchase list) -// (It isn't and shouldn't be like this in the GRF files since new cargo types -// may appear in future - however it's more convenient to store it like this in -// memory. --pasky) -static const SpriteGroup *engine_custom_sprites[TOTAL_NUM_ENGINES][NUM_GLOBAL_CID]; +/* Space for NUM_CARGO real cargos and 2 pseudo cargos, CT_DEFAULT and CT_PURCHASE */ +static const SpriteGroup *_engine_custom_sprites[TOTAL_NUM_ENGINES][NUM_CARGO + 2]; static const GRFFile *_engine_grf[TOTAL_NUM_ENGINES]; void SetCustomEngineSprites(EngineID engine, byte cargo, const SpriteGroup *group) { - assert(engine < TOTAL_NUM_ENGINES); - assert(cargo < NUM_GLOBAL_CID); + assert(engine < lengthof(_engine_custom_sprites)); + assert(cargo < lengthof(*_engine_custom_sprites)); - if (engine_custom_sprites[engine][cargo] != NULL) { + if (_engine_custom_sprites[engine][cargo] != NULL) { grfmsg(6, "SetCustomEngineSprites: engine %d cargo %d already has group -- replacing", engine, cargo); } - engine_custom_sprites[engine][cargo] = group; + _engine_custom_sprites[engine][cargo] = group; } /** @@ -163,15 +125,8 @@ */ void UnloadCustomEngineSprites(void) { - EngineID engine; - CargoID cargo; - - for (engine = 0; engine < TOTAL_NUM_ENGINES; engine++) { - for (cargo = 0; cargo < NUM_GLOBAL_CID; cargo++) { - engine_custom_sprites[engine][cargo] = NULL; - } - _engine_grf[engine] = 0; - } + memset(_engine_custom_sprites, 0, sizeof(_engine_custom_sprites)); + memset(_engine_grf, 0, sizeof(_engine_grf)); } static const SpriteGroup *heli_rotor_custom_sprites[NUM_AIRCRAFT_ENGINES]; @@ -574,10 +529,9 @@ const Vehicle *u; byte cargo_classes = 0; uint common_cargo_best = 0; - uint common_cargos[NUM_GLOBAL_CID]; + uint common_cargos[NUM_CARGO]; byte user_def_data = 0; - CargoID cargo; - CargoID common_cargo_type = GC_PASSENGERS; + CargoID common_cargo_type = CT_PASSENGERS; /* Reset our arrays */ memset(common_cargos, 0, sizeof(common_cargos)); @@ -585,18 +539,17 @@ for (u = v; u != NULL; u = u->next) { /* Skip empty engines */ if (u->cargo_cap == 0) continue; - /* Map from climate to global cargo ID */ - cargo = _global_cargo_id[_opt.landscape][u->cargo_type]; - cargo_classes |= _cargo_classes[cargo]; - common_cargos[cargo]++; + + cargo_classes |= GetCargo(u->cargo_type)->classes; + common_cargos[u->cargo_type]++; user_def_data |= RailVehInfo(u->engine_type)->user_def_data; } /* Pick the most common cargo type */ - for (cargo = 0; cargo < NUM_GLOBAL_CID; cargo++) { + for (CargoID cargo = 0; cargo < NUM_CARGO; cargo++) { if (common_cargos[cargo] > common_cargo_best) { common_cargo_best = common_cargos[cargo]; - common_cargo_type = cargo; + common_cargo_type = GetCargo(cargo)->bitnum; } } @@ -643,9 +596,9 @@ * ww - cargo unit weight in 1/16 tons, same as cargo prop. 0F. * cccc - the cargo class value of the cargo transported by the vehicle. */ - CargoID cid = _global_cargo_id[_opt.landscape][v->cargo_type]; + const CargoSpec *cs = GetCargo(v->cargo_type); - return (_cargo_classes[cid] << 16) | (_cargoc.weights[v->cargo_type] << 8) | cid; + return (cs->classes << 16) | (cs->weight << 8) | GetEngineGRF(v->engine_type)->cargo_map[v->cargo_type]; } case 0x48: return GetVehicleTypeInfo(v->engine_type); /* Vehicle Type Info */ @@ -855,10 +808,9 @@ CargoID cargo; if (v == NULL) { - cargo = GC_PURCHASE; + cargo = CT_PURCHASE; } else { - cargo = _global_cargo_id[_opt.landscape][v->cargo_type]; - assert(cargo != GC_INVALID); + cargo = v->cargo_type; if (v->type == VEH_Train) { group = GetWagonOverrideSpriteSet(engine, cargo, v->u.rail.first_engine); @@ -867,11 +819,11 @@ } } - group = engine_custom_sprites[engine][cargo]; + group = _engine_custom_sprites[engine][cargo]; if (group != NULL) return group; /* Fall back to the default set if the selected cargo type is not defined */ - return engine_custom_sprites[engine][GC_DEFAULT]; + return _engine_custom_sprites[engine][CT_DEFAULT]; } @@ -923,7 +875,7 @@ bool UsesWagonOverride(const Vehicle* v) { assert(v->type == VEH_Train); - return GetWagonOverrideSpriteSet(v->engine_type, _global_cargo_id[_opt.landscape][v->cargo_type], v->u.rail.first_engine) != NULL; + return GetWagonOverrideSpriteSet(v->engine_type, v->cargo_type, v->u.rail.first_engine) != NULL; } /** diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/newgrf_gui.cpp --- a/src/newgrf_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/newgrf_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -11,6 +11,7 @@ #include "table/sprites.h" #include "newgrf.h" #include "newgrf_config.h" +#include "strings.h" #include "helpers.hpp" @@ -43,6 +44,25 @@ { char buff[256]; + if (c->error != NULL) { + SetDParamStr(0, c->filename); + SetDParam(1, c->error->data); + for (uint i = 0; i < c->error->num_params; i++) { + uint32 param = 0; + byte param_number = c->error->param_number[i]; + + if (param_number < c->num_params) param = c->param[param_number]; + + SetDParam(2 + i, param); + } + + char message[512]; + GetString(message, c->error->message, lastof(message)); + + SetDParamStr(0, message); + y += DrawStringMultiLine(x, y, c->error->severity, w); + } + /* Draw filename or not if it is not known (GRF sent over internet) */ if (c->filename != NULL) { SetDParamStr(0, c->filename); @@ -328,7 +348,8 @@ } DrawSprite(SPR_SQUARE, pal, 5, y + 2); - DoDrawString(text, 25, y + 3, WP(w, newgrf_d).sel == c ? 0xC : 0x10); + if (c->error != NULL) DrawSprite(SPR_WARNING_SIGN, 0, 20, y + 2); + DoDrawString(text, c->error != NULL ? 35 : 25, y + 3, WP(w, newgrf_d).sel == c ? 0xC : 0x10); y += 14; } } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/newgrf_sound.cpp --- a/src/newgrf_sound.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/newgrf_sound.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -37,7 +37,7 @@ FileEntry *GetSound(uint index) { - if (index >= _sound_count) return NULL; + if (index >= GetNumSounds()) return NULL; return GetSoundInternal(index); } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/newgrf_station.cpp --- a/src/newgrf_station.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/newgrf_station.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,6 +1,6 @@ /* $Id$ */ -/** @file newgrf_station.c Functions for dealing with station classes and custom stations. */ +/** @file newgrf_station.cpp Functions for dealing with station classes and custom stations. */ #include "stdafx.h" #include "openttd.h" @@ -18,6 +18,7 @@ #include "newgrf_spritegroup.h" #include "date.h" #include "helpers.hpp" +#include "cargotype.h" static StationClass station_classes[STAT_CLASS_MAX]; @@ -200,8 +201,8 @@ uint32 retval = 0; if (axis == AXIS_X) { - intswap(platforms, length); - intswap(x, y); + Swap(platforms, length); + Swap(x, y); } /* Limit our sizes to 4 bits */ @@ -446,20 +447,20 @@ } switch (cargo_type) { - case GC_INVALID: - case GC_DEFAULT_NA: - case GC_PURCHASE: + case CT_INVALID: + case CT_DEFAULT_NA: + case CT_PURCHASE: cargo = 0; break; - case GC_DEFAULT: + case CT_DEFAULT: for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { cargo += GB(st->goods[cargo_type].waiting_acceptance, 0, 12); } break; default: - cargo = GB(st->goods[_local_cargo_id_ctype[cargo_type]].waiting_acceptance, 0, 12); + cargo = GB(st->goods[cargo_type].waiting_acceptance, 0, 12); break; } @@ -505,20 +506,17 @@ static const SpriteGroup *ResolveStation(ResolverObject *object) { const SpriteGroup *group; - CargoID ctype = GC_DEFAULT_NA; + CargoID ctype = CT_DEFAULT_NA; if (object->u.station.st == NULL) { /* No station, so we are in a purchase list */ - ctype = GC_PURCHASE; + ctype = CT_PURCHASE; } else { - CargoID cargo; - /* Pick the first cargo that we have waiting */ - for (cargo = 0; cargo < NUM_GLOBAL_CID; cargo++) { - CargoID lcid = _local_cargo_id_ctype[cargo]; - if (lcid != CT_INVALID && - object->u.station.statspec->spritegroup[cargo] != NULL && - GB(object->u.station.st->goods[lcid].waiting_acceptance, 0, 12) != 0) { + for (CargoID cargo = 0; cargo < NUM_CARGO; cargo++) { + const CargoSpec *cs = GetCargo(cargo); + if (cs->IsValid() && object->u.station.statspec->spritegroup[cargo] != NULL && + GB(object->u.station.st->goods[cargo].waiting_acceptance, 0, 12) != 0) { ctype = cargo; break; } @@ -527,7 +525,7 @@ group = object->u.station.statspec->spritegroup[ctype]; if (group == NULL) { - ctype = GC_DEFAULT; + ctype = CT_DEFAULT; group = object->u.station.statspec->spritegroup[ctype]; } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/newgrf_station.h --- a/src/newgrf_station.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/newgrf_station.h Wed Feb 28 00:33:40 2007 +0000 @@ -79,11 +79,11 @@ bool copied_layouts; /** - * NUM_GLOBAL_CID sprite groups. + * NUM_CARGO real cargo plus three pseudo cargo sprite groups. * Used for obtaining the sprite offset of custom sprites, and for * evaluating callbacks. */ - const struct SpriteGroup *spritegroup[NUM_GLOBAL_CID]; + const struct SpriteGroup *spritegroup[NUM_CARGO + 3]; } StationSpec; /** diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/npf.cpp --- a/src/npf.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/npf.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -594,7 +594,7 @@ /* check correct rail type (mono, maglev, etc) */ if (type == TRANSPORT_RAIL) { - RailType dst_type = GetTileRailType(dst_tile, TrackdirToTrack(src_trackdir)); + RailType dst_type = GetTileRailType(dst_tile); if (!HASBIT(aystar->user_data[NPF_RAILTYPES], dst_type)) return; } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/oldloader.cpp --- a/src/oldloader.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/oldloader.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -372,6 +372,7 @@ static uint32 _old_town_index; static uint16 _old_string_id; static uint16 _old_string_id_2; +static uint16 _old_extra_chunk_nums; static void ReadTTDPatchFlags(void) { @@ -397,6 +398,8 @@ /* Check if we have a modern TTDPatch savegame (has extra data all around) */ _new_ttdpatch_format = (memcmp(&_old_map3[0x1FFFA], "TTDp", 4) == 0); + _old_extra_chunk_nums = _old_map3[_new_ttdpatch_format ? 0x1FFFE : 0x2]; + /* Clean the misused places */ for (i = 0; i < 17; i++) _old_map3[i] = 0; for (i = 0x1FE00; i < 0x20000; i++) _old_map3[i] = 0; @@ -1345,6 +1348,60 @@ return !ls->failed; } +static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num) +{ + ReadTTDPatchFlags(); + + DEBUG(oldloader, 2, "Found %d extra chunk(s)", _old_extra_chunk_nums); + + for (int i = 0; i != _old_extra_chunk_nums; i++) { + uint16 id = ReadUint16(ls); + uint32 len = ReadUint32(ls); + + switch (id) { + /* List of GRFIDs, used in the savegame. 0x8004 is the new ID + * They are saved in a 'GRFID:4 active:1' format, 5 bytes for each entry */ + case 0x2: + case 0x8004: { + /* Skip the first element: TTDP hack for the Action D special variables (FFFF0000 01) */ + ReadUint32(ls); ReadByte(ls); len -= 5; + + ClearGRFConfigList(&_grfconfig); + while (len != 0) { + uint32 grfid = ReadUint32(ls); + + if (ReadByte(ls) == 1) { + GRFConfig *c = CallocT(1); + c->grfid = grfid; + c->filename = strdup("TTDP game, no information"); + + AppendToGRFConfigList(&_grfconfig, c); + DEBUG(oldloader, 3, "TTDPatch game using GRF file with GRFID %0X", BSWAP32(c->grfid)); + } + len -= 5; + }; + + /* Append static NewGRF configuration */ + AppendStaticGRFConfigs(&_grfconfig); + } break; + + case 0x3: { /* TTDPatch version and configuration */ + uint32 ttdpv = ReadUint32(ls); + DEBUG(oldloader, 3, "Game saved with TTDPatch version %d.%d.%d r%d", GB(ttdpv, 24, 8), GB(ttdpv, 20, 4), GB(ttdpv, 16, 4), GB(ttdpv, 0, 16)); + len -= 4; + while (len-- != 0) ReadByte(ls); // skip the configuration + } break; + + default: + DEBUG(oldloader, 4, "Skipping unknown extra chunk %X", id); + while (len-- != 0) ReadByte(ls); + break; + } + } + + return !ls->failed; +} + static uint32 _old_cur_town_ctr; static const OldChunks main_chunk[] = { OCL_ASSERT( 0 ), @@ -1458,6 +1515,7 @@ OCL_ASSERT( 0x97179 ), /* Below any (if available) extra chunks from TTDPatch can follow */ + OCL_CHUNK(1, LoadTTDPatchExtraChunks), OCL_END() }; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/openttd.cpp --- a/src/openttd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/openttd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1288,20 +1288,23 @@ DoZoomInOutWindow(ZOOM_NONE, w); // update button status MarkWholeScreenDirty(); - /* From this version on there can be multiple road stops of the same type per - * station. Convert the existing stops to the new internal data structure. - */ for (TileIndex t = 0; t < map_size; t++) { switch (GetTileType(t)) { - case MP_STATION: + case MP_STATION: { + Station *st = GetStationByTile(t); + + st->rect.BeforeAddTile(t, StationRect::ADD_FORCE); + switch (GetStationType(t)) { case STATION_TRUCK: case STATION_BUS: if (CheckSavegameVersion(6)) { + /* From this version on there can be multiple road stops of the + * same type per station. Convert the existing stops to the new + * internal data structure. */ RoadStop *rs = new RoadStop(t); if (rs == NULL) error("Too many road stops in savegame"); - Station *st = GetStationByTile(t); RoadStop **head = IsTruckStop(t) ? &st->truck_stops : &st->bus_stops; *head = rs; @@ -1330,6 +1333,7 @@ default: break; } break; + } default: break; } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/order_cmd.cpp --- a/src/order_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/order_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -167,6 +167,16 @@ } +static TileIndex GetOrderLocation(const Order& o) +{ + switch (o.type) { + default: NOT_REACHED(); + case OT_GOTO_STATION: return GetStation(o.dest)->xy; + case OT_GOTO_DEPOT: return GetDepot(o.dest)->xy; + } +} + + /** Add an order to the orderlist of a vehicle. * @param tile unused * @param p1 various bitstuffed elements @@ -198,7 +208,7 @@ if (!IsValidStationID(new_order.dest)) return CMD_ERROR; st = GetStation(new_order.dest); - if (st->airport_type != AT_OILRIG && !st->IsBuoy() && !CheckOwnership(st->owner)) { + if (st->owner != OWNER_NONE && !CheckOwnership(st->owner)) { return CMD_ERROR; } @@ -343,18 +353,29 @@ * handle any more then this.. */ if (v->num_orders >= MAX_BACKUP_ORDER_COUNT) return_cmd_error(STR_8832_TOO_MANY_ORDERS); - /* For ships, make sure that the station is not too far away from the - * previous destination, for human players with new pathfinding disabled */ - if (v->type == VEH_Ship && IsHumanPlayer(v->owner) && - sel_ord != 0 && GetVehicleOrder(v, sel_ord - 1)->type == OT_GOTO_STATION - && !_patches.new_pathfinding_all) { + if (v->type == VEH_Ship && + IsHumanPlayer(v->owner) && + !_patches.new_pathfinding_all) { + // Make sure the new destination is not too far away from the previous + const Order *prev = NULL; + uint n = 0; - int dist = DistanceManhattan( - GetStation(GetVehicleOrder(v, sel_ord - 1)->dest)->xy, - GetStation(new_order.dest)->xy // XXX type != OT_GOTO_STATION? - ); - if (dist >= 130) - return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO); + /* Find the last goto station or depot order before the insert location. + * If the order is to be inserted at the beginning of the order list this + * finds the last order in the list. */ + for (const Order *o = v->orders; o != NULL; o = o->next) { + if (o->type == OT_GOTO_STATION || o->type == OT_GOTO_DEPOT) prev = o; + if (++n == sel_ord && prev != NULL) break; + } + if (prev != NULL) { + uint dist = DistanceManhattan( + GetOrderLocation(*prev), + GetOrderLocation(new_order) + ); + if (dist >= 130) { + return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO); + } + } } if (flags & DC_EXEC) { diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/order_gui.cpp --- a/src/order_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/order_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -22,6 +22,7 @@ #include "train.h" #include "water_map.h" #include "vehicle_gui.h" +#include "cargotype.h" enum OrderWindowWidgets { ORDER_WIDGET_CLOSEBOX = 0, @@ -180,7 +181,7 @@ SetDParam(1, s); if (order->refit_cargo < NUM_CARGO) { SetDParam(3, STR_REFIT_ORDER); - SetDParam(4, _cargoc.names_s[order->refit_cargo]); + SetDParam(4, GetCargo(order->refit_cargo)->name); } else { SetDParam(3, STR_EMPTY); } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/players.cpp --- a/src/players.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/players.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,7 +1,6 @@ /* $Id$ */ -/** @file players.c - * @todo Cleanup the messy DrawPlayerFace function asap +/** @file players.cpp */ #include "stdafx.h" #include "openttd.h" @@ -65,161 +64,151 @@ DrawSprite(SPR_PLAYER_ICON, PLAYER_SPRITE_COLOR(p), x, y); } +/** The gender/race combinations that we have faces for */ +enum GenderRace { + GENDER_FEMALE = 0, ///< This bit set means a female, otherwise male + RACE_BLACK = 1, ///< This bit set means black, otherwise white -static const SpriteID cheeks_table[4] = { - 0x325, 0x326, - 0x390, 0x3B0, + WHITE_MALE = 0, ///< A male of Caucasian origin + WHITE_FEMALE = 1 << GENDER_FEMALE, ///< A female of Caucasian origin + BLACK_MALE = 1 << RACE_BLACK, ///< A male of African origin + BLACK_FEMALE = 1 << RACE_BLACK | 1 << GENDER_FEMALE, ///< A female of African origin }; +DECLARE_ENUM_AS_BIT_SET(GenderRace); ///< See GenderRace as a bitset -static const SpriteID mouth_table[3] = { - 0x34C, 0x34D, 0x34F -}; - +/** + * Draws the face of a player. + * + * Meaning of the bits in face (some bits are used in several times): + * - 4 and 5: chin + * - 6 to 9: eyebrows + * - 10 to 13: nose + * - 13 to 15: lips (also moustache for males) + * - 16 to 19: hair + * - 20 to 22: eye color + * - 20 to 27: tie, ear rings etc. + * - 28 to 30: glasses + * - 19, 26 and 27: race (bit 27 set and bit 19 equal to bit 26 = black, otherwise white) + * - 31: gender (0 = male, 1 = female) + * + * @param face the bit-encoded representation of the face + * @param color the (background) color of the gradient + * @param x x-position to draw the face + * @param y y-position to draw the face + * + * @note all magic hexadecimal numbers in this function as sprite IDs. + * @todo replace magic hexadecimal numbers with enums + */ void DrawPlayerFace(uint32 face, int color, int x, int y) { - byte flag = 0; + GenderRace gen_race = WHITE_MALE; - if ( (int32)face < 0) - flag |= 1; - if ((((((face >> 7) ^ face) >> 7) ^ face) & 0x8080000) == 0x8000000) - flag |= 2; + if (HASBIT(face, 31)) SetBitT(gen_race, GENDER_FEMALE); + if (HASBIT(face, 27) && (HASBIT(face, 26) == HASBIT(face, 19))) SetBitT(gen_race, RACE_BLACK); - /* draw the gradient */ + /* Draw the gradient (background) */ DrawSprite(SPR_GRADIENT, GENERAL_SPRITE_COLOR(color), x, y); - /* draw the cheeks */ - DrawSprite(cheeks_table[flag&3], PAL_NONE, x, y); - - /* draw the chin */ - /* FIXME: real code uses -2 in zoomlevel 1 */ - { - uint val = GB(face, 4, 2); - if (!(flag & 2)) { - DrawSprite(0x327 + (flag&1?0:val), PAL_NONE, x, y); - } else { - DrawSprite((flag&1?0x3B1:0x391) + (val>>1), PAL_NONE, x, y); - } - } - /* draw the eyes */ - { - uint val1 = GB(face, 6, 4); - uint val2 = GB(face, 20, 3); - SpriteID pal; + /* Draw the cheeks */ + static const SpriteID cheeks_table[] = { 0x325, 0x326, 0x390, 0x3B0 }; + DrawSprite(cheeks_table[gen_race], PAL_NONE, x, y); - if (val2 < 6) { - pal = PALETTE_TO_BROWN; - } else if (val2 == 6) { - pal = PALETTE_TO_BLUE; - } else { - pal = PALETTE_TO_GREEN; - } - - if (!(flag & 2)) { - if (!(flag & 1)) { - DrawSprite(0x32B + (val1 * 12 >> 4), pal, x, y); - } else { - DrawSprite(0x337 + val1, pal, x, y); - } - } else { - if (!(flag & 1)) { - DrawSprite(0x39A + (val1 * 11 >> 4), pal, x, y); - } else { - DrawSprite(0x3B8 + val1, pal, x, y); - } - } + /* Draw the chin */ + uint chin = GB(face, 4, 2); + if (HASBIT(gen_race, RACE_BLACK)) { + DrawSprite((HASBIT(gen_race, GENDER_FEMALE) ? 0x3B1 : 0x391) + (chin >> 1), PAL_NONE, x, y); + } else { + DrawSprite(0x327 + (HASBIT(gen_race, GENDER_FEMALE) ? 0 : chin), PAL_NONE, x, y); } - /* draw the mouth */ - { - uint val = GB(face, 10, 6); - uint val2; - - if (!(flag&1)) { - val2 = ((val&0xF) * 15 >> 4); + /* Draw the eyes */ + uint eye_colour = GB(face, 20, 3); + uint eyebrows = GB(face, 6, 4); + SpriteID pal; - if (val2 < 3) { - DrawSprite((flag&2 ? 0x397 : 0x367) + val2, PAL_NONE, x, y); - /* skip the rest */ - goto skip_mouth; - } + if (eye_colour < 6) { + pal = PALETTE_TO_BROWN; + } else if (eye_colour == 6) { + pal = PALETTE_TO_BLUE; + } else { + pal = PALETTE_TO_GREEN; + } - val2 -= 3; - if (flag & 2) { - if (val2 > 8) val2 = 0; - val2 += 0x3A5 - 0x35B; - } - DrawSprite(val2 + 0x35B, PAL_NONE, x, y); - } else if (!(flag&2)) { - DrawSprite(((val&0xF) * 10 >> 4) + 0x351, PAL_NONE, x, y); - } else { - DrawSprite(((val&0xF) * 9 >> 4) + 0x3C8, PAL_NONE, x, y); + switch (gen_race) { + case WHITE_MALE: DrawSprite(0x32B + (eyebrows * 12 >> 4), pal, x, y); break; + case WHITE_FEMALE: DrawSprite(0x337 + eyebrows, pal, x, y); break; + case BLACK_MALE: DrawSprite(0x39A + (eyebrows * 11 >> 4), pal, x, y); break; + case BLACK_FEMALE: DrawSprite(0x3B8 + eyebrows, pal, x, y); break; + } + + /* Draw the mouth */ + uint nose = GB(face, 13, 3); + uint lips = GB(face, 10, 4); + + if (!HASBIT(gen_race, GENDER_FEMALE)) { + lips = (lips * 15 >> 4); + + if (lips < 3) { + /* Moustache, including nose and lips */ + DrawSprite((HASBIT(gen_race, RACE_BLACK) ? 0x397 : 0x367) + lips, PAL_NONE, x, y); + + /* Skip the rest */ + goto skip_mouth; } - val >>= 3; - - if (!(flag&2)) { - if (!(flag&1)) { - DrawSprite(0x349 + val, PAL_NONE, x, y); - } else { - DrawSprite( mouth_table[(val*3>>3)], PAL_NONE, x, y); - } - } else { - if (!(flag&1)) { - DrawSprite(0x393 + (val&3), PAL_NONE, x, y); - } else { - DrawSprite(0x3B3 + (val*5>>3), PAL_NONE, x, y); - } + /* Lips */ + lips -= 3; + if (HASBIT(gen_race, RACE_BLACK)) { + if (lips > 8) lips = 0; + lips += 0x3A5 - 0x35B; } - - skip_mouth:; + DrawSprite(lips + 0x35B, PAL_NONE, x, y); + } else if (HASBIT(gen_race, RACE_BLACK)) { + /* Female lips with make up */ + DrawSprite((lips * 9 >> 4) + 0x3C8, PAL_NONE, x, y); + } else { + /* Female lips */ + DrawSprite((lips * 10 >> 4) + 0x351, PAL_NONE, x, y); } - - /* draw the hair */ { - uint val = GB(face, 16, 4); - if (flag & 2) { - if (flag & 1) { - DrawSprite(0x3D9 + (val * 5 >> 4), PAL_NONE, x, y); - } else { - DrawSprite(0x3D4 + (val * 5 >> 4), PAL_NONE, x, y); - } - } else { - if (flag & 1) { - DrawSprite(0x38B + (val * 5 >> 4), PAL_NONE, x, y); - } else { - DrawSprite(0x382 + (val * 9 >> 4), PAL_NONE, x, y); - } + /* Nose */ + static const SpriteID mouth_table[] = { 0x34C, 0x34D, 0x34F }; + switch (gen_race) { + case WHITE_MALE: DrawSprite(0x349 + nose, PAL_NONE, x, y); break; + case WHITE_FEMALE: DrawSprite(mouth_table[(nose * 3 >> 3)], PAL_NONE, x, y); break; + case BLACK_MALE: DrawSprite(0x393 + (nose & 3), PAL_NONE, x, y); break; + case BLACK_FEMALE: DrawSprite(0x3B3 + (nose * 5 >> 3), PAL_NONE, x, y); break; } } - - /* draw the tie */ - { - uint val = GB(face, 20, 8); +skip_mouth: - if (!(flag&1)) { - DrawSprite(0x36B + (GB(val, 0, 2) * 3 >> 2), PAL_NONE, x, y); - DrawSprite(0x36E + (GB(val, 2, 2) * 4 >> 2), PAL_NONE, x, y); - DrawSprite(0x372 + (GB(val, 4, 4) * 6 >> 4), PAL_NONE, x, y); - } else { - DrawSprite(0x378 + (GB(val, 0, 2) * 3 >> 2), PAL_NONE, x, y); - DrawSprite(0x37B + (GB(val, 2, 2) * 4 >> 2), PAL_NONE, x, y); + /* Draw the hair */ + uint hair = GB(face, 16, 4); + switch (gen_race) { + case WHITE_MALE: DrawSprite(0x382 + (hair * 9 >> 4), PAL_NONE, x, y); break; + case WHITE_FEMALE: DrawSprite(0x38B + (hair * 5 >> 4), PAL_NONE, x, y); break; + case BLACK_MALE: DrawSprite(0x3D4 + (hair * 5 >> 4), PAL_NONE, x, y); break; + case BLACK_FEMALE: DrawSprite(0x3D9 + (hair * 5 >> 4), PAL_NONE, x, y); break; + } - val >>= 4; - if (val < 3) DrawSprite((flag & 2 ? 0x3D1 : 0x37F) + val, PAL_NONE, x, y); - } + /* Draw the tie, ear rings etc. */ + uint tie = GB(face, 20, 8); + if (HASBIT(gen_race, GENDER_FEMALE)) { + DrawSprite(0x378 + (GB(tie, 0, 2) * 3 >> 2), PAL_NONE, x, y); + DrawSprite(0x37B + (GB(tie, 2, 2) * 4 >> 2), PAL_NONE, x, y); + + tie >>= 4; + if (tie < 3) DrawSprite((HASBIT(gen_race, RACE_BLACK) ? 0x3D1 : 0x37F) + tie, PAL_NONE, x, y); + } else { + DrawSprite(0x36B + (GB(tie, 0, 2) * 3 >> 2), PAL_NONE, x, y); + DrawSprite(0x36E + (GB(tie, 2, 2) * 4 >> 2), PAL_NONE, x, y); + DrawSprite(0x372 + (GB(tie, 4, 4) * 6 >> 4), PAL_NONE, x, y); } /* draw the glasses */ - { - uint val = GB(face, 28, 3); - - if (flag & 2) { - if (val <= 1) DrawSprite(0x3AE + val, PAL_NONE, x, y); - } else { - if (val <= 1) DrawSprite(0x347 + val, PAL_NONE, x, y); - } - } + uint glasses = GB(face, 28, 3); + if (glasses <= 1) DrawSprite((HASBIT(gen_race, RACE_BLACK) ? 0x3AE : 0x347) + glasses, PAL_NONE, x, y); } void InvalidatePlayerWindows(const Player *p) diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/queue.cpp --- a/src/queue.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/queue.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -5,140 +5,6 @@ #include "queue.h" #include "helpers.hpp" -static void Stack_Clear(Queue* q, bool free_values) -{ - if (free_values) { - uint i; - - for (i = 0; i < q->data.stack.size; i++) free(q->data.stack.elements[i]); - } - q->data.stack.size = 0; -} - -static void Stack_Free(Queue* q, bool free_values) -{ - q->clear(q, free_values); - free(q->data.stack.elements); - if (q->freeq) free(q); -} - -static bool Stack_Push(Queue* q, void* item, int priority) -{ - if (q->data.stack.size == q->data.stack.max_size) return false; - q->data.stack.elements[q->data.stack.size++] = item; - return true; -} - -static void* Stack_Pop(Queue* q) -{ - if (q->data.stack.size == 0) return NULL; - return q->data.stack.elements[--q->data.stack.size]; -} - -static bool Stack_Delete(Queue* q, void* item, int priority) -{ - return false; -} - -static Queue* init_stack(Queue* q, uint max_size) -{ - q->push = Stack_Push; - q->pop = Stack_Pop; - q->del = Stack_Delete; - q->clear = Stack_Clear; - q->free = Stack_Free; - q->data.stack.max_size = max_size; - q->data.stack.size = 0; - q->data.stack.elements = MallocT(max_size); - q->freeq = false; - return q; -} - -Queue* new_Stack(uint max_size) -{ - Queue* q = MallocT(1); - - init_stack(q, max_size); - q->freeq = true; - return q; -} - -/* - * Fifo - */ - -static void Fifo_Clear(Queue* q, bool free_values) -{ - if (free_values) { - uint head = q->data.fifo.head; - uint tail = q->data.fifo.tail; /* cache for speed */ - - while (head != tail) { - free(q->data.fifo.elements[tail]); - tail = (tail + 1) % q->data.fifo.max_size; - } - } - q->data.fifo.head = 0; - q->data.fifo.tail = 0; -} - -static void Fifo_Free(Queue* q, bool free_values) -{ - q->clear(q, free_values); - free(q->data.fifo.elements); - if (q->freeq) free(q); -} - -static bool Fifo_Push(Queue* q, void* item, int priority) -{ - uint next = (q->data.fifo.head + 1) % q->data.fifo.max_size; - - if (next == q->data.fifo.tail) return false; - q->data.fifo.elements[q->data.fifo.head] = item; - - q->data.fifo.head = next; - return true; -} - -static void* Fifo_Pop(Queue* q) -{ - void* result; - - if (q->data.fifo.head == q->data.fifo.tail) return NULL; - result = q->data.fifo.elements[q->data.fifo.tail]; - - q->data.fifo.tail = (q->data.fifo.tail + 1) % q->data.fifo.max_size; - return result; -} - -static bool Fifo_Delete(Queue* q, void* item, int priority) -{ - return false; -} - -static Queue* init_fifo(Queue* q, uint max_size) -{ - q->push = Fifo_Push; - q->pop = Fifo_Pop; - q->del = Fifo_Delete; - q->clear = Fifo_Clear; - q->free = Fifo_Free; - q->data.fifo.max_size = max_size; - q->data.fifo.head = 0; - q->data.fifo.tail = 0; - q->data.fifo.elements = MallocT(max_size); - q->freeq = false; - return q; -} - -Queue* new_Fifo(uint max_size) -{ - Queue* q = MallocT(1); - init_fifo(q, max_size); - q->freeq = true; - return q; -} - /* * Insertion Sorter @@ -161,7 +27,6 @@ static void InsSort_Free(Queue* q, bool free_values) { q->clear(q, free_values); - if (q->freeq) free(q); } static bool InsSort_Push(Queue* q, void* item, int priority) @@ -215,16 +80,6 @@ q->clear = InsSort_Clear; q->free = InsSort_Free; q->data.inssort.first = NULL; - q->freeq = false; -} - -Queue* new_InsSort(void) -{ - Queue* q = MallocT(1); - - init_InsSort(q); - q->freeq = true; - return q; } @@ -284,7 +139,6 @@ free(q->data.binaryheap.elements[i]); } free(q->data.binaryheap.elements); - if (q->freeq) free(q); } static bool BinaryHeap_Push(Queue* q, void* item, int priority) @@ -430,21 +284,11 @@ q->data.binaryheap.elements = CallocT((max_size - 1) / BINARY_HEAP_BLOCKSIZE + 1); q->data.binaryheap.elements[0] = MallocT(BINARY_HEAP_BLOCKSIZE); q->data.binaryheap.blocks = 1; - q->freeq = false; #ifdef QUEUE_DEBUG printf("[BinaryHeap] Initial size of elements is %d nodes\n", BINARY_HEAP_BLOCKSIZE); #endif } -Queue* new_BinaryHeap(uint max_size) -{ - Queue* q = MallocT(1); - - init_BinaryHeap(q, max_size); - q->freeq = true; - return q; -} - // Because we don't want anyone else to bother with our defines #undef BIN_HEAP_ARR @@ -469,18 +313,9 @@ debug("Buckets = %p", h->buckets); #endif h->buckets_in_use = (bool*)(h->buckets + num_buckets); - h->freeh = false; for (i = 0; i < num_buckets; i++) h->buckets_in_use[i] = false; } -Hash* new_Hash(Hash_HashProc* hash, int num_buckets) -{ - Hash* h = MallocT(1); - - init_Hash(h, hash, num_buckets); - h->freeh = true; - return h; -} void delete_Hash(Hash* h, bool free_values) { @@ -511,7 +346,6 @@ #ifdef HASH_DEBUG debug("Freeing Hash: %p", h); #endif - if (h->freeh) free(h); } #ifdef HASH_STATS diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/queue.h --- a/src/queue.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/queue.h Wed Feb 28 00:33:40 2007 +0000 @@ -61,17 +61,6 @@ union { struct { - uint max_size; - uint size; - void** elements; - } stack; - struct { - uint max_size; - uint head; /* The index where the last element should be inserted */ - uint tail; /* The index where the next element should be read */ - void** elements; - } fifo; - struct { InsSortNode* first; } inssort; struct { @@ -81,32 +70,8 @@ BinaryHeapNode** elements; } binaryheap; } data; - - /* If true, this struct will be free'd when the - * Queue is deleted. */ - bool freeq; }; -/* Initializes a stack and allocates internal memory. */ -void init_Stack(Queue* q, uint max_size); - -/* Allocate a new stack with a maximum of max_size elements. */ -Queue* new_Stack(uint max_size); - -/* - * Fifo - */ - -/* Initializes a fifo and allocates internal memory for maximum of max_size - * elements */ -void init_Fifo(Queue* q, uint max_size); - -/* Allocate a new fifo and initializes it with a maximum of max_size elements. */ -Queue* new_Fifo(uint max_size); - -Queue* new_Fifo_in_buffer(uint max_size, void* buffer); - -int build_Fifo(void* buffer, uint size); /* * Insertion Sorter @@ -116,8 +81,6 @@ * size */ void init_InsSort(Queue* q); -/* Allocate a new fifo and initializes it. There is no maximum size */ -Queue* new_InsSort(void); /* * Binary Heap @@ -132,9 +95,6 @@ * max_size elements */ void init_BinaryHeap(Queue* q, uint max_size); -/* Allocate a new binary heap and initializes it with a maximum of max_size - * elements. */ -Queue* new_BinaryHeap(uint max_size); /* * Hash @@ -163,10 +123,6 @@ /* A pointer to an array of numbuckets booleans, which will be true if * there are any Nodes in the bucket */ bool* buckets_in_use; - /* If true, buckets will be freed in delete_hash */ - bool freeb; - /* If true, the pointer to this struct will be freed in delete_hash */ - bool freeh; } Hash; /* Call these function to manipulate a hash */ @@ -184,9 +140,6 @@ /* Call these function to create/destroy a hash */ -/* Builds a new hash, with num_buckets buckets. Make sure that hash() always - * returns a hash less than num_buckets! Call delete_hash after use */ -Hash* new_Hash(Hash_HashProc* hash, int num_buckets); /* Builds a new hash in an existing struct. Make sure that hash() always * returns a hash less than num_buckets! Call delete_hash after use */ void init_Hash(Hash* h, Hash_HashProc* hash, uint num_buckets); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/rail.cpp --- a/src/rail.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/rail.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -102,7 +102,7 @@ }; -RailType GetTileRailType(TileIndex tile, Track track) +RailType GetTileRailType(TileIndex tile) { switch (GetTileType(tile)) { case MP_RAILWAY: diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/rail.h --- a/src/rail.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/rail.h Wed Feb 28 00:33:40 2007 +0000 @@ -88,7 +88,6 @@ typedef TinyEnumT TrackBitsByte; DECLARE_ENUM_AS_BIT_SET(TrackBits); -DECLARE_ENUM_AS_BIT_INDEX(Track, TrackBits); /** * Maps a Track to the corresponding TrackBits value @@ -261,7 +260,7 @@ { if (*tracks != TRACK_BIT_NONE && *tracks != INVALID_TRACK_BIT) { Track first = (Track)FIND_FIRST_BIT(*tracks); - *tracks = ClrBitT(*tracks, first); + ClrBitT(*tracks, first); return first; } return INVALID_TRACK; @@ -274,7 +273,7 @@ { if (*trackdirs != TRACKDIR_BIT_NONE && *trackdirs != INVALID_TRACKDIR_BIT) { Trackdir first = (Trackdir)FindFirstBit2x64(*trackdirs); - *trackdirs = ClrBitT(*trackdirs, first); + ClrBitT(*trackdirs, first); return first; } return INVALID_TRACKDIR; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/rail_cmd.cpp --- a/src/rail_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/rail_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -3,6 +3,7 @@ #include "stdafx.h" #include "openttd.h" #include "bridge_map.h" +#include "cmd_helper.h" #include "debug.h" #include "functions.h" #include "rail_map.h" @@ -450,7 +451,7 @@ (trdy >= 0 && dy < 0) ) { if (!HASBIT(*trackdir, 3)) { // first direction is invalid, try the other - *trackdir = SetBitT(*trackdir, 3); // reverse the direction + SetBitT(*trackdir, 3); // reverse the direction trdx = -trdx; trdy = -trdy; } else { // other direction is invalid too, invalid drag @@ -513,7 +514,7 @@ tile += ToTileIndexDiff(_trackdelta[trackdir]); // toggle railbit for the non-diagonal tracks - if (!IsDiagonalTrackdir(trackdir)) trackdir = ToggleBitT(trackdir, 0); + if (!IsDiagonalTrackdir(trackdir)) ToggleBitT(trackdir, 0); } return (total_cost == 0) ? CMD_ERROR : total_cost; @@ -540,7 +541,7 @@ /** Build a train depot * @param tile position of the train depot * @param p1 rail type - * @param p2 entrance direction (DiagDirection) + * @param p2 bit 0..1 entrance direction (DiagDirection) * * @todo When checking for the tile slope, * distingush between "Flat land required" and "land sloped in wrong direction" @@ -553,12 +554,13 @@ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - if (!EnsureNoVehicle(tile)) return CMD_ERROR; /* check railtype and valid direction for depot (0 through 3), 4 in total */ - if (!ValParamRailtype(p1) || p2 > 3) return CMD_ERROR; + if (!ValParamRailtype(p1)) return CMD_ERROR; tileh = GetTileSlope(tile, NULL); + DiagDirection dir = Extract(p2); + /* Prohibit construction if * The tile is non-flat AND * 1) The AI is "old-school" @@ -571,7 +573,7 @@ _is_old_ai_player || !_patches.build_on_slopes || IsSteepSlope(tileh) || - !CanBuildDepotByTileh(p2, tileh) + !CanBuildDepotByTileh(dir, tileh) )) { return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); } @@ -586,7 +588,6 @@ if (d == NULL) return CMD_ERROR; if (flags & DC_EXEC) { - DiagDirection dir = (DiagDirection)p2; MakeRailDepot(tile, _current_player, dir, (RailType)p1); MarkTileDirtyByTile(tile); @@ -777,7 +778,7 @@ signal_ctr++; // toggle railbit for the non-diagonal tracks (|, -- tracks) - if (!IsDiagonalTrackdir(trackdir)) trackdir = ToggleBitT(trackdir, 0); + if (!IsDiagonalTrackdir(trackdir)) ToggleBitT(trackdir, 0); } return error ? CMD_ERROR : total_cost; @@ -914,8 +915,8 @@ ey = TileY(tile); sx = TileX(p1); sy = TileY(p1); - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); money = GetAvailableMoneyForCommand(); cost = 0; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/rail_gui.cpp --- a/src/rail_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/rail_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,6 +1,6 @@ /* $Id$ */ -/** @file rail_gui.c File for dealing with rail construction user interface */ +/** @file rail_gui.cpp File for dealing with rail construction user interface */ #include "stdafx.h" #include "openttd.h" @@ -638,11 +638,11 @@ uint ey = TileY(end); uint w,h; - if (sx > ex) uintswap(sx,ex); - if (sy > ey) uintswap(sy,ey); + if (sx > ex) Swap(sx, ex); + if (sy > ey) Swap(sy, ey); w = ex - sx + 1; h = ey - sy + 1; - if (!_railstation.orientation) uintswap(w,h); + if (!_railstation.orientation) Swap(w, h); DoCommandP(TileXY(sx, sy), _railstation.orientation | (w << 8) | (h << 16), @@ -704,7 +704,7 @@ } else { int x = _railstation.numtracks; int y = _railstation.platlength; - if (_railstation.orientation == 0) intswap(x,y); + if (_railstation.orientation == 0) Swap(x, y); if (!_remove_button_clicked) SetTileSelectSize(x, y); } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/rail_map.h --- a/src/rail_map.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/rail_map.h Wed Feb 28 00:33:40 2007 +0000 @@ -261,12 +261,8 @@ /** * Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile. - * Note that there is no check if the given trackdir is actually present on - * the tile! - * The given trackdir is used when there are (could be) multiple rail types on - * one tile. */ -RailType GetTileRailType(TileIndex tile, Track track); +RailType GetTileRailType(TileIndex tile); typedef enum RailGroundType { diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/road.h --- a/src/road.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/road.h Wed Feb 28 00:33:40 2007 +0000 @@ -40,4 +40,14 @@ return (dir & 0x06) == 0; } +/** + * Is it allowed to remove the given road bits from the given tile? + * @param tile the tile to remove the road from + * @param remove the roadbits that are going to be removed + * @param owner the actual owner of the roadbits of the tile + * @param edge_road are the removed bits from a town? + * @return true when it is allowed to remove the road bits + */ +bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road); + #endif /* ROAD_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/road_cmd.cpp --- a/src/road_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/road_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -3,6 +3,7 @@ #include "stdafx.h" #include "openttd.h" #include "bridge_map.h" +#include "cmd_helper.h" #include "rail_map.h" #include "road_map.h" #include "sprite.h" @@ -35,11 +36,10 @@ } -static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool* edge_road) +bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road) { RoadBits present; RoadBits n; - Owner owner; *edge_road = true; if (_game_mode == GM_EDITOR) return true; @@ -47,8 +47,6 @@ // Only do the special processing for actual players. if (!IsValidPlayer(_current_player)) return true; - owner = IsLevelCrossingTile(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile); - // Only do the special processing if the road is owned // by a town if (owner != OWNER_TOWN) return (owner == OWNER_NONE) || CheckOwnership(owner); @@ -81,10 +79,14 @@ return true; } +static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool *edge_road) +{ + return CheckAllowRemoveRoad(tile, remove, IsLevelCrossingTile(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile), edge_road); +} /** Delete a piece of road. * @param tile tile where to remove road from - * @param p1 road piece flags + * @param p1 bit 0..3 road pieces to remove (RoadBits) * @param p2 unused */ int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) @@ -97,14 +99,9 @@ /* true if the roadpiece was always removeable, * false if it was a center piece. Affects town ratings drop */ bool edge_road; - RoadBits pieces; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - /* Road pieces are max 4 bitset values (NE, NW, SE, SW) */ - if (p1 >> 4) return CMD_ERROR; - pieces = (RoadBits)p1; - if (!IsTileType(tile, MP_STREET)) return CMD_ERROR; owner = IsLevelCrossingTile(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile); @@ -115,6 +112,8 @@ t = NULL; } + RoadBits pieces = Extract(p1); + if (!CheckAllowRemoveRoad(tile, pieces, &edge_road)) return CMD_ERROR; if (!EnsureNoVehicle(tile)) return CMD_ERROR; @@ -248,7 +247,7 @@ /** Build a piece of road. * @param tile tile where to build road - * @param p1 road piece flags + * @param p1 bit 0..3 road pieces to build (RoadBits) * @param p2 the town that is building the road (0 if not applicable) */ int32 CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) @@ -256,15 +255,15 @@ int32 cost = 0; int32 ret; RoadBits existing = ROAD_NONE; - RoadBits pieces; Slope tileh; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); /* Road pieces are max 4 bitset values (NE, NW, SE, SW) and town can only be non-zero * if a non-player is building the road */ - if ((p1 >> 4) || (IsValidPlayer(_current_player) && p2 != 0) || (_current_player == OWNER_TOWN && !IsValidTownID(p2))) return CMD_ERROR; - pieces = (RoadBits)p1; + if ((IsValidPlayer(_current_player) && p2 != 0) || (_current_player == OWNER_TOWN && !IsValidTownID(p2))) return CMD_ERROR; + + RoadBits pieces = Extract(p1); tileh = GetTileSlope(tile, NULL); @@ -501,7 +500,7 @@ /** Build a road depot. * @param tile tile where to build the depot - * @param p1 entrance direction (DiagDirection) + * @param p1 bit 0..1 entrance direction (DiagDirection) * @param p2 unused * * @todo When checking for the tile slope, @@ -515,15 +514,13 @@ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - if (p1 > 3) return CMD_ERROR; // check direction - - if (!EnsureNoVehicle(tile)) return CMD_ERROR; + DiagDirection dir = Extract(p1); tileh = GetTileSlope(tile, NULL); if (tileh != SLOPE_FLAT && ( !_patches.build_on_slopes || IsSteepSlope(tileh) || - !CanBuildDepotByTileh(p1, tileh) + !CanBuildDepotByTileh(dir, tileh) )) { return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); } @@ -540,7 +537,7 @@ dep->xy = tile; dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index; - MakeRoadDepot(tile, _current_player, (DiagDirection)p1); + MakeRoadDepot(tile, _current_player, dir); MarkTileDirtyByTile(tile); } return cost + _price.build_road_depot; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/road_gui.cpp --- a/src/road_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/road_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -84,7 +84,9 @@ if (success) { SndPlayTileFx(SND_1F_SPLAT, tile); ResetObjectToPlace(); - if (!HASBIT(p2, 1)) BuildRoadOutsideStation(tile, (DiagDirection)p1); + BuildRoadOutsideStation(tile, (DiagDirection)p1); + /* For a drive-through road stop build connecting road for other entrance */ + if (HASBIT(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir((DiagDirection)p1)); } } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/roadveh_cmd.cpp --- a/src/roadveh_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/roadveh_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -880,7 +880,9 @@ // Clamp spd = min(spd, v->max_speed); - if (v->u.road.state == RVSB_WORMHOLE) spd = min(spd, SetSpeedLimitOnBridge(v)); + if (v->u.road.state == RVSB_WORMHOLE && !(v->vehstatus & VS_HIDDEN)) { + spd = min(spd, GetBridge(GetBridgeType(v->tile))->speed * 2); + } //updates statusbar only if speed have changed to save CPU time if (spd != v->cur_speed) { @@ -972,7 +974,7 @@ if (v->direction != u->direction || !(v->direction & 1)) return; /* Check if vehicle is in a road stop, depot, tunnel or bridge or not on a straight road */ - if (v->u.road.state >= RVS_IN_ROAD_STOP || !IsStraightRoadTrackdir((Trackdir)(v->u.road.state & RVSB_TRACKDIR_MASK))) return; + if (v->u.road.state >= RVSB_IN_ROAD_STOP || !IsStraightRoadTrackdir((Trackdir)(v->u.road.state & RVSB_TRACKDIR_MASK))) return; tt = GetTileTrackStatus(v->tile, TRANSPORT_ROAD) & 0x3F; if ((tt & 3) == 0) return; @@ -1355,9 +1357,7 @@ if (v->u.road.state == RVSB_WORMHOLE) { /* Vehicle is entering a depot or is on a bridge or in a tunnel */ - GetNewVehiclePosResult gp; - - GetNewVehiclePos(v, &gp); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); const Vehicle *u = RoadVehFindCloseTo(v, gp.x, gp.y, v->direction); if (u != NULL && u->cur_speed < v->cur_speed) { diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/saveload.cpp --- a/src/saveload.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/saveload.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,6 +1,6 @@ /* $Id$ */ -/** @file +/** @file saveload.cpp * All actions handling saving and loading goes on in this file. The general actions * are as follows for saving a game (loading is analogous): *
        @@ -12,8 +12,6 @@ *
      1. when the buffer is full; flush it to the output (eg save to file) (_sl.buf, _sl.bufp, _sl.bufe) *
      2. repeat this until everything is done, and flush any remaining output to file *
      - * @see ChunkHandler - * @see SaveLoad */ #include "stdafx.h" #include "openttd.h" @@ -31,43 +29,43 @@ #include extern const uint16 SAVEGAME_VERSION = 47; -uint16 _sl_version; /// the major savegame version identifier -byte _sl_minor_version; /// the minor savegame version, DO NOT USE! +uint16 _sl_version; ///< the major savegame version identifier +byte _sl_minor_version; ///< the minor savegame version, DO NOT USE! typedef void WriterProc(uint len); typedef uint ReaderProc(void); /** The saveload struct, containing reader-writer functions, bufffer, version, etc. */ static struct { - bool save; /// are we doing a save or a load atm. True when saving - byte need_length; /// ??? - byte block_mode; /// ??? - bool error; /// did an error occur or not - - int obj_len; /// the length of the current object we are busy with - int array_index, last_array_index; /// in the case of an array, the current and last positions - - uint32 offs_base; /// the offset in number of bytes since we started writing data (eg uncompressed savegame size) - - WriterProc *write_bytes; /// savegame writer function - ReaderProc *read_bytes; /// savegame loader function + bool save; ///< are we doing a save or a load atm. True when saving + byte need_length; ///< ??? + byte block_mode; ///< ??? + bool error; ///< did an error occur or not - const ChunkHandler* const *chs; /// the chunk of data that is being processed atm (vehicles, signs, etc.) - const SaveLoad* const *includes; /// the internal layouf of the given chunk - - /** When saving/loading savegames, they are always saved to a temporary memory-place - * to be flushed to file (save) or to final place (load) when full. */ - byte *bufp, *bufe; /// bufp(ointer) gives the current position in the buffer bufe(nd) gives the end of the buffer + int obj_len; ///< the length of the current object we are busy with + int array_index, last_array_index; ///< in the case of an array, the current and last positions - // these 3 may be used by compressor/decompressors. - byte *buf; /// pointer to temporary memory to read/write, initialized by SaveLoadFormat->initread/write - byte *buf_ori; /// pointer to the original memory location of buf, used to free it afterwards - uint bufsize; /// the size of the temporary memory *buf - FILE *fh; /// the file from which is read or written to + uint32 offs_base; ///< the offset in number of bytes since we started writing data (eg uncompressed savegame size) - void (*excpt_uninit)(void); /// the function to execute on any encountered error - const char *excpt_msg; /// the error message - jmp_buf excpt; /// @todo used to jump to "exception handler"; really ugly + WriterProc *write_bytes; ///< savegame writer function + ReaderProc *read_bytes; ///< savegame loader function + + const ChunkHandler* const *chs; ///< the chunk of data that is being processed atm (vehicles, signs, etc.) + const SaveLoad* const *includes; ///< the internal layouf of the given chunk + + /* When saving/loading savegames, they are always saved to a temporary memory-place + * to be flushed to file (save) or to final place (load) when full. */ + byte *bufp, *bufe; ///< bufp(ointer) gives the current position in the buffer bufe(nd) gives the end of the buffer + + /* these 3 may be used by compressor/decompressors. */ + byte *buf; ///< pointer to temporary memory to read/write, initialized by SaveLoadFormat->initread/write + byte *buf_ori; ///< pointer to the original memory location of buf, used to free it afterwards + uint bufsize; ///< the size of the temporary memory *buf + FILE *fh; ///< the file from which is read or written to + + void (*excpt_uninit)(void); ///< the function to execute on any encountered error + const char *excpt_msg; ///< the error message + jmp_buf excpt; ///< @todo used to jump to "exception handler"; really ugly } _sl; @@ -89,8 +87,8 @@ static inline uint32 SlGetOffs(void) {return _sl.offs_base - (_sl.bufe - _sl.bufp);} /** Return the size in bytes of a certain type of normal/atomic variable - * as it appears in memory. @see VarTypes - * @param conv @VarType type of variable that is used for calculating the size + * as it appears in memory. See VarTypes + * @param conv VarType type of variable that is used for calculating the size * @return Return the size of this type in bytes */ static inline byte SlCalcConvMemLen(VarType conv) { @@ -101,8 +99,8 @@ } /** Return the size in bytes of a certain type of normal/atomic variable - * as it appears in a saved game. @see VarTypes - * @param conv @VarType type of variable that is used for calculating the size + * as it appears in a saved game. See VarTypes + * @param conv VarType type of variable that is used for calculating the size * @return Return the size of this type in bytes */ static inline byte SlCalcConvFileLen(VarType conv) { @@ -112,7 +110,7 @@ return conv_file_size[length]; } -/* Return the size in bytes of a reference (pointer) */ +/** Return the size in bytes of a reference (pointer) */ static inline size_t SlCalcRefLen(void) {return 2;} /** Flush the output buffer by writing to disk with the given reader. @@ -121,7 +119,7 @@ */ static void SlWriteFill(void) { - // flush the buffer to disk (the writer) + /* flush the buffer to disk (the writer) */ if (_sl.bufp != NULL) { uint len = _sl.bufp - _sl.buf; _sl.offs_base += len; @@ -129,7 +127,7 @@ } /* All the data from the buffer has been written away, rewind to the beginning - * to start reading in more data */ + * to start reading in more data */ _sl.bufp = _sl.buf; _sl.bufe = _sl.buf + _sl.bufsize; } @@ -333,9 +331,9 @@ _sl.need_length = NL_NONE; switch (_sl.block_mode) { case CH_RIFF: - // Ugly encoding of >16M RIFF chunks - // The lower 24 bits are normal - // The uppermost 4 bits are bits 24:27 + /* Ugly encoding of >16M RIFF chunks + * The lower 24 bits are normal + * The uppermost 4 bits are bits 24:27 */ assert(length < (1<<28)); SlWriteUint32((length & 0xFFFFFF) | ((length >> 24) << 28)); break; @@ -439,13 +437,13 @@ * and then write them to file, endian safely. Loading a value * goes exactly the opposite way * @param ptr The object being filled/read - * @param conv @VarType type of the current element of the struct + * @param conv VarType type of the current element of the struct */ static void SlSaveLoadConv(void *ptr, VarType conv) { int64 x = 0; - if (_sl.save) { /* SAVE values */ + if (_sl.save) { // SAVE values /* Read a value from the struct. These ARE endian safe. */ x = ReadValue(ptr, conv); @@ -462,7 +460,7 @@ case SLE_FILE_U64: SlWriteUint64(x);break; default: NOT_REACHED(); } - } else { /* LOAD values */ + } else { // LOAD values /* Read a value from the file */ switch (GetVarFileType(conv)) { @@ -533,7 +531,7 @@ { size_t len; - if (_sl.save) { /* SAVE string */ + if (_sl.save) { // SAVE string switch (GetVarMemType(conv)) { default: NOT_REACHED(); case SLE_VAR_STRB: @@ -549,7 +547,7 @@ SlWriteArrayLength(len); SlCopyBytes(ptr, len); - } else { /* LOAD string */ + } else { // LOAD string len = SlReadArrayLength(); switch (GetVarMemType(conv)) { @@ -566,7 +564,7 @@ } break; case SLE_VAR_STR: - case SLE_VAR_STRQ: /* Malloc'd string, free previous incarnation, and allocate */ + case SLE_VAR_STRQ: // Malloc'd string, free previous incarnation, and allocate free(*(char**)ptr); *(char**)ptr = (char*)malloc(len + 1); // terminating '\0' ptr = *(char**)ptr; @@ -581,7 +579,7 @@ /** * Return the size in bytes of a certain type of atomic array * @param length The length of the array counted in elements - * @param conv @VarType type of the variable that is used in calculating the size + * @param conv VarType type of the variable that is used in calculating the size */ static inline size_t SlCalcArrayLen(uint length, VarType conv) { @@ -592,14 +590,14 @@ * Save/Load an array. * @param array The array being manipulated * @param length The length of the array in elements - * @param conv @VarType type of the atomic array (int, byte, uint64, etc.) + * @param conv VarType type of the atomic array (int, byte, uint64, etc.) */ void SlArray(void *array, uint length, VarType conv) { - // Automatically calculate the length? + /* Automatically calculate the length? */ if (_sl.need_length != NL_NONE) { SlSetLength(SlCalcArrayLen(length, conv)); - // Determine length only? + /* Determine length only? */ if (_sl.need_length == NL_CALCLENGTH) return; } @@ -628,7 +626,7 @@ } } -/* Are we going to save this object or not? */ +/** Are we going to save this object or not? */ static inline bool SlIsObjectValidInSavegame(const SaveLoad *sld) { if (_sl_version < sld->version_from || _sl_version > sld->version_to) return false; @@ -652,13 +650,13 @@ /** * Calculate the size of an object. - * @param sld The @SaveLoad description of the object so we know how to manipulate it + * @param sld The SaveLoad description of the object so we know how to manipulate it */ static size_t SlCalcObjLength(const void *object, const SaveLoad *sld) { size_t length = 0; - // Need to determine the length and write a length tag. + /* Need to determine the length and write a length tag. */ for (; sld->cmd != SL_END; sld++) { length += SlCalcObjMemberLength(object, sld); } @@ -711,8 +709,8 @@ switch (sld->cmd) { case SL_VAR: SlSaveLoadConv(ptr, conv); break; - case SL_REF: /* Reference variable, translate */ - /// @todo XXX - another artificial limitof 65K elements of pointers? + case SL_REF: // Reference variable, translate + /* @todo XXX - another artificial limitof 65K elements of pointers? */ if (_sl.save) { // XXX - read/write pointer as uint16? What is with higher indeces? SlWriteUint16(ReferenceToInt(*(void**)ptr, (SLRefType)conv)); } else { @@ -726,10 +724,10 @@ break; /* SL_WRITEBYTE translates a value of a variable to another one upon - * saving or loading. - * XXX - variable renaming abuse - * game_value: the value of the variable ingame is abused by sld->version_from - * file_value: the value of the variable in the savegame is abused by sld->version_to */ + * saving or loading. + * XXX - variable renaming abuse + * game_value: the value of the variable ingame is abused by sld->version_from + * file_value: the value of the variable in the savegame is abused by sld->version_to */ case SL_WRITEBYTE: if (_sl.save) { SlWriteByte(sld->version_to); @@ -752,11 +750,11 @@ /** * Main SaveLoad function. * @param object The object that is being saved or loaded - * @param sld The @SaveLoad description of the object so we know how to manipulate it + * @param sld The SaveLoad description of the object so we know how to manipulate it */ void SlObject(void *object, const SaveLoad *sld) { - // Automatically calculate the length? + /* Automatically calculate the length? */ if (_sl.need_length != NL_NONE) { SlSetLength(SlCalcObjLength(object, sld)); if (_sl.need_length == NL_CALCLENGTH) return; @@ -795,18 +793,18 @@ assert(_sl.save); - // Tell it to calculate the length + /* Tell it to calculate the length */ _sl.need_length = NL_CALCLENGTH; _sl.obj_len = 0; proc(arg); - // Setup length + /* Setup length */ _sl.need_length = NL_WANTLENGTH; SlSetLength(_sl.obj_len); offs = SlGetOffs() + _sl.obj_len; - // And write the stuff + /* And write the stuff */ proc(arg); assert(offs == SlGetOffs()); @@ -835,7 +833,7 @@ break; default: if ((m & 0xF) == CH_RIFF) { - // Read length + /* Read length */ len = (SlReadByte() << 16) | ((m >> 4) << 24); len += SlReadUint16(); _sl.obj_len = len; @@ -866,7 +864,7 @@ DEBUG(sl, 2, "Saving chunk %c%c%c%c", ch->id >> 24, ch->id >> 16, ch->id >> 8, ch->id); if (ch->flags & CH_AUTO_LENGTH) { - // Need to calculate the length. Solve that by calling SlAutoLength in the save_proc. + /* Need to calculate the length. Solve that by calling SlAutoLength in the save_proc. */ _tmp_proc_1 = proc; proc = SlStubSaveProc; } @@ -911,7 +909,7 @@ } } - // Terminator + /* Terminator */ SlWriteUint32(0); } @@ -949,9 +947,9 @@ } } -//******************************************* -//********** START OF LZO CODE ************** -//******************************************* +/******************************************* + ********** START OF LZO CODE ************** + *******************************************/ #define LZO_SIZE 8192 #include "minilzo.h" @@ -963,10 +961,10 @@ uint32 size; uint len; - // Read header + /* Read header*/ if (fread(tmp, sizeof(tmp), 1, _sl.fh) != 1) SlError("file read failed"); - // Check if size is bad + /* Check if size is bad */ ((uint32*)out)[0] = size = tmp[1]; if (_sl_version != 0) { @@ -976,19 +974,19 @@ if (size >= sizeof(out)) SlError("inconsistent size"); - // Read block + /* Read block */ if (fread(out + sizeof(uint32), size, 1, _sl.fh) != 1) SlError("file read failed"); - // Verify checksum + /* Verify checksum */ if (tmp[0] != lzo_adler32(0, out, size + sizeof(uint32))) SlError("bad checksum"); - // Decompress + /* Decompress */ lzo1x_decompress(out + sizeof(uint32)*1, size, _sl.buf, &len, NULL); return len; } -// p contains the pointer to the buffer, len contains the pointer to the length. -// len bytes will be written, p and l will be updated to reflect the next buffer. +/* p contains the pointer to the buffer, len contains the pointer to the length. + * len bytes will be written, p and l will be updated to reflect the next buffer. */ static void WriteLZO(uint size) { byte out[LZO_SIZE + LZO_SIZE / 64 + 16 + 3 + 8]; @@ -1013,9 +1011,9 @@ free(_sl.buf_ori); } -//********************************************* -//******** START OF NOCOMP CODE (uncompressed)* -//********************************************* +/********************************************* + ******** START OF NOCOMP CODE (uncompressed)* + *********************************************/ static uint ReadNoComp(void) { return fread(_sl.buf, 1, LZO_SIZE, _sl.fh); @@ -1038,9 +1036,9 @@ free(_sl.buf_ori); } -//******************************************** -//********** START OF MEMORY CODE (in ram)**** -//******************************************** +/******************************************** + ********** START OF MEMORY CODE (in ram)**** + ********************************************/ #include "table/strings.h" #include "table/sprites.h" @@ -1084,9 +1082,9 @@ _sl.buf = GetSavegame(_ts.count); } -//******************************************** -//********** START OF ZLIB CODE ************** -//******************************************** +/******************************************** + ********** START OF ZLIB CODE ************** + ********************************************/ #if defined(WITH_ZLIB) #include @@ -1111,12 +1109,12 @@ _z.avail_out = 4096; do { - // read more bytes from the file? + /* read more bytes from the file?*/ if (_z.avail_in == 0) { _z.avail_in = fread(_z.next_in = _sl.buf + 4096, 1, 4096, _sl.fh); } - // inflate the data + /* inflate the data */ r = inflate(&_z, 0); if (r == Z_STREAM_END) break; @@ -1155,7 +1153,7 @@ z->next_out = buf; z->avail_out = sizeof(buf); r = deflate(z, mode); - // bytes were emitted? + /* bytes were emitted? */ if ((n=sizeof(buf) - z->avail_out) != 0) { if (fwrite(buf, n, 1, _sl.fh) != 1) SlError("file write error"); } @@ -1172,7 +1170,7 @@ static void UninitWriteZlib(void) { - // flush any pending output. + /* flush any pending output. */ if (_sl.fh) WriteZlibLoop(&_z, NULL, 0, Z_FINISH); deflateEnd(&_z); free(_sl.buf_ori); @@ -1180,11 +1178,11 @@ #endif /* WITH_ZLIB */ -//******************************************* -//************* END OF CODE ***************** -//******************************************* +/******************************************* + ************* END OF CODE ***************** + *******************************************/ -// these define the chunks +/* these define the chunks */ extern const ChunkHandler _misc_chunk_handlers[]; extern const ChunkHandler _setting_chunk_handlers[]; extern const ChunkHandler _player_chunk_handlers[]; @@ -1220,7 +1218,7 @@ NULL, }; -// used to include a vehicle desc in another desc. +/* used to include a vehicle desc in another desc. */ extern const SaveLoad _common_veh_desc[]; static const SaveLoad* const _desc_includes[] = { _common_veh_desc @@ -1233,7 +1231,7 @@ * Remember that a NULL item has value 0, and all * indeces have +1, so vehicle 0 is saved as index 1. * @param obj The object that we want to get the index of - * @param rt @SLRefType type of the object the index is being sought of + * @param rt SLRefType type of the object the index is being sought of * @return Return the pointer converted to an index of the type pointed to */ static uint ReferenceToInt(const void *obj, SLRefType rt) @@ -1261,7 +1259,7 @@ * Remember that an index of 0 is a NULL pointer so all indeces * are +1 so vehicle 0 is saved as 1. * @param index The index that is being converted to a pointer - * @param rt @SLRefType type of the object the pointer is sought of + * @param rt SLRefType type of the object the pointer is sought of * @return Return the index converted to a pointer of any type */ static void *IntToReference(uint index, SLRefType rt) @@ -1329,16 +1327,16 @@ /** The format for a reader/writer type of a savegame */ typedef struct { - const char *name; /// name of the compressor/decompressor (debug-only) - uint32 tag; /// the 4-letter tag by which it is identified in the savegame + const char *name; ///< name of the compressor/decompressor (debug-only) + uint32 tag; ///< the 4-letter tag by which it is identified in the savegame - bool (*init_read)(void); /// function executed upon initalization of the loader - ReaderProc *reader; /// function that loads the data from the file - void (*uninit_read)(void); /// function executed when reading is finished + bool (*init_read)(void); ///< function executed upon initalization of the loader + ReaderProc *reader; ///< function that loads the data from the file + void (*uninit_read)(void); ///< function executed when reading is finished - bool (*init_write)(void); /// function executed upon intialization of the saver - WriterProc *writer; /// function that saves the data to the file - void (*uninit_write)(void); /// function executed when writing is done + bool (*init_write)(void); ///< function executed upon intialization of the saver + WriterProc *writer; ///< function that saves the data to the file + void (*uninit_write)(void); ///< function executed when writing is done } SaveLoadFormat; static const SaveLoadFormat _saveload_formats[] = { @@ -1356,13 +1354,13 @@ * Return the savegameformat of the game. Whether it was create with ZLIB compression * uncompressed, or another type * @param s Name of the savegame format. If NULL it picks the first available one - * @return Pointer to @SaveLoadFormat struct giving all characteristics of this type of savegame + * @return Pointer to SaveLoadFormat struct giving all characteristics of this type of savegame */ static const SaveLoadFormat *GetSavegameFormat(const char *s) { const SaveLoadFormat *def = endof(_saveload_formats) - 1; - // find default savegame format, the highest one with which files can be written + /* find default savegame format, the highest one with which files can be written */ while (!def->init_write) def--; if (s != NULL && s[0] != '\0') { @@ -1377,7 +1375,7 @@ return def; } -// actual loader/saver function +/* actual loader/saver function */ void InitializeGame(int mode, uint size_x, uint size_y); extern bool AfterLoadGame(void); extern void BeforeSaveGame(void); @@ -1509,7 +1507,7 @@ /* An instance of saving is already active, so don't go saving again */ if (_ts.saveinprogress && mode == SL_SAVE) { - // if not an autosave, but a user action, show error message + /* if not an autosave, but a user action, show error message */ if (!_do_autosave) ShowErrorMessage(INVALID_STRING_ID, STR_SAVE_STILL_IN_PROGRESS, 0, 0); return SL_OK; } @@ -1541,7 +1539,7 @@ if (setjmp(_sl.excpt)) { AbortSaveLoad(); - // deinitialize compressor. + /* deinitialize compressor. */ _sl.excpt_uninit(); /* A saver/loader exception!! reinitialize all variables to prevent crash! */ @@ -1590,7 +1588,7 @@ return AbortSaveLoad(); } - // see if we have any loader for this type. + /* see if we have any loader for this type. */ for (fmt = _saveload_formats; ; fmt++) { /* No loader found, treat as version 0 and use LZO format */ if (fmt == endof(_saveload_formats)) { @@ -1609,12 +1607,12 @@ } if (fmt->tag == hdr[0]) { - // check version number + /* check version number */ _sl_version = TO_BE32(hdr[1]) >> 16; /* Minor is not used anymore from version 18.0, but it is still needed - * in versions before that (4 cases) which can't be removed easy. - * Therefor it is loaded, but never saved (or, it saves a 0 in any scenario). - * So never EVER use this minor version again. -- TrueLight -- 22-11-2005 */ + * in versions before that (4 cases) which can't be removed easy. + * Therefor it is loaded, but never saved (or, it saves a 0 in any scenario). + * So never EVER use this minor version again. -- TrueLight -- 22-11-2005 */ _sl_minor_version = (TO_BE32(hdr[1]) >> 8) & 0xFF; DEBUG(sl, 1, "Loading savegame version %d", _sl_version); @@ -1631,7 +1629,7 @@ _sl.read_bytes = fmt->reader; _sl.excpt_uninit = fmt->uninit_read; - // loader for this savegame type is not implemented? + /* loader for this savegame type is not implemented? */ if (fmt->init_read == NULL) { ShowInfoF("Loader for '%s' is not available.", fmt->name); return AbortSaveLoad(); @@ -1686,7 +1684,7 @@ DEBUG(sl, 0, "Savegame is obsolete or invalid format"); mode = SL_LOAD; // don't try to get filename, just show name as it is written } else { - // see if we have any loader for this type. + /* see if we have any loader for this type. */ for (fmt = _saveload_formats; fmt != endof(_saveload_formats); fmt++) { if (fmt->tag == hdr) { mode = SL_LOAD; // new type of savegame diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/ship_cmd.cpp --- a/src/ship_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/ship_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -662,7 +662,6 @@ static void ShipController(Vehicle *v) { - GetNewVehiclePosResult gp; uint32 r; const byte *b; Direction dir; @@ -692,7 +691,8 @@ BeginVehicleMove(v); - if (GetNewVehiclePos(v, &gp)) { + GetNewVehiclePosResult gp = GetNewVehiclePos(v); + if (gp.old_tile == gp.new_tile) { /* Staying in tile */ if (IsShipInDepot(v)) { gp.x = v->x_pos; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/sound/cocoa_s.h --- a/src/sound/cocoa_s.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/sound/cocoa_s.h Wed Feb 28 00:33:40 2007 +0000 @@ -7,4 +7,4 @@ extern const HalSoundDriver _cocoa_sound_driver; -#endif +#endif /* SOUND_COCOA_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/sound/sdl_s.cpp --- a/src/sound/sdl_s.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/sound/sdl_s.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,10 +1,9 @@ /* $Id$ */ +#ifdef WITH_SDL + #include "../stdafx.h" -#ifdef WITH_SDL - -#include "../openttd.h" #include "../driver.h" #include "../mixer.h" #include "../sdl.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/sound/win32_s.h --- a/src/sound/win32_s.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/sound/win32_s.h Wed Feb 28 00:33:40 2007 +0000 @@ -7,4 +7,4 @@ extern const HalSoundDriver _win32_sound_driver; -#endif +#endif /* SOUND_WIN32_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/station.cpp --- a/src/station.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/station.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,6 +1,6 @@ /* $Id$ */ -/** @file station_cmd.c */ +/** @file station.cpp */ #include "stdafx.h" #include "openttd.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/station.h --- a/src/station.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/station.h Wed Feb 28 00:33:40 2007 +0000 @@ -205,13 +205,13 @@ HVOT_BUOY = 1 << 6 }; -typedef enum CatchmentAeras { +typedef enum CatchmentAreas { CA_NONE = 0, CA_BUS = 3, CA_TRUCK = 3, CA_TRAIN = 4, CA_DOCK = 5 -} CatchmentAera; +} CatchmentArea; void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/station_cmd.cpp --- a/src/station_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/station_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,10 +1,12 @@ /* $Id$ */ -/** @file station_cmd.c */ +/** @file station_cmd.cpp */ #include "stdafx.h" #include "openttd.h" +#include "aircraft.h" #include "bridge_map.h" +#include "cmd_helper.h" #include "debug.h" #include "functions.h" #include "station_map.h" @@ -36,24 +38,21 @@ #include "helpers.hpp" #include "misc/autoptr.hpp" #include "road.h" +#include "cargotype.h" /** * Called if a new block is added to the station-pool */ static void StationPoolNewBlock(uint start_item) { - Station *st; - /* We don't use FOR_ALL here, because FOR_ALL skips invalid items. * TODO - This is just a temporary stage, this will be removed. */ - for (st = GetStation(start_item); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : NULL) st->index = start_item++; + for (Station *st = GetStation(start_item); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : NULL) st->index = start_item++; } static void StationPoolCleanBlock(uint start_item, uint end_item) { - uint i; - - for (i = start_item; i <= end_item; i++) { + for (uint i = start_item; i <= end_item; i++) { Station *st = GetStation(i); if (st->IsValid()) st->~Station(); } @@ -64,11 +63,9 @@ */ static void RoadStopPoolNewBlock(uint start_item) { - RoadStop *rs; - /* We don't use FOR_ALL here, because FOR_ALL skips invalid items. * TODO - This is just a temporary stage, this will be removed. */ - for (rs = GetRoadStop(start_item); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) { + for (RoadStop *rs = GetRoadStop(start_item); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) { rs->xy = INVALID_TILE; rs->index = start_item++; } @@ -78,29 +75,25 @@ DEFINE_OLD_POOL(RoadStop, RoadStop, RoadStopPoolNewBlock, NULL) -extern void UpdateAirplanesOnNewStation(Station *st); - - RoadStop* GetRoadStopByTile(TileIndex tile, RoadStop::Type type) { const Station* st = GetStationByTile(tile); - RoadStop* rs; - - for (rs = st->GetPrimaryRoadStop(type); rs->xy != tile; rs = rs->next) { + + for (RoadStop *rs = st->GetPrimaryRoadStop(type);; rs = rs->next) { + if (rs->xy == tile) return rs; assert(rs->next != NULL); } - - return rs; } static uint GetNumRoadStopsInStation(const Station* st, RoadStop::Type type) { uint num = 0; - const RoadStop *rs; assert(st != NULL); - for (rs = st->GetPrimaryRoadStop(type); rs != NULL; rs = rs->next) num++; + for (const RoadStop *rs = st->GetPrimaryRoadStop(type); rs != NULL; rs = rs->next) { + num++; + } return num; } @@ -129,12 +122,6 @@ BEGIN_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1)) if (IsTileType(tile_cur, MP_STATION)) { StationID t = GetStationIndex(tile_cur); - { - Station *st = GetStation(t); - // you cannot take control of an oilrig!! - if (st->airport_type == AT_OILRIG && st->facilities == (FACIL_AIRPORT|FACIL_DOCK)) - continue; - } if (closest_station == INVALID_STATION) { closest_station = t; @@ -147,29 +134,6 @@ return (closest_station == INVALID_STATION) ? NULL : GetStation(closest_station); } -static Station *AllocateStation(void) -{ - Station *st = NULL; - - /* We don't use FOR_ALL here, because FOR_ALL skips invalid items. - * TODO - This is just a temporary stage, this will be removed. */ - for (st = GetStation(0); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : NULL) { - if (!st->IsValid()) { - StationID index = st->index; - - memset(st, 0, sizeof(Station)); - st->index = index; - return st; - } - } - - /* Check if we can add a block to the pool */ - if (AddBlockToPool(&_Station_pool)) return AllocateStation(); - - _error_message = STR_3008_TOO_MANY_STATIONS_LOADING; - return NULL; -} - /** * Counts the numbers of tiles matching a specific type in the area around @@ -181,13 +145,11 @@ */ static int CountMapSquareAround(TileIndex tile, TileType type, IndustryType industry) { - TileIndex cur_tile; - int dx, dy; int num = 0; - for (dx = -3; dx <= 3; dx++) { - for (dy = -3; dy <= 3; dy++) { - cur_tile = TILE_MASK(tile + TileDiffXY(dx, dy)); + for (int dx = -3; dx <= 3; dx++) { + for (int dy = -3; dy <= 3; dy++) { + TileIndex cur_tile = TILE_MASK(tile + TileDiffXY(dx, dy)); if (IsTileType(cur_tile, type)) { switch (type) { @@ -230,7 +192,6 @@ Town *t = st->town; uint32 free_names = (uint32)-1; int found; - uint z,z2; unsigned long tmp; { @@ -295,14 +256,16 @@ } /* check elevation compared to town */ - z = GetTileZ(tile); - z2 = GetTileZ(t->xy); - if (z < z2) { - found = M(STR_SV_STNAME_VALLEY); - if (HASBIT(free_names, M(STR_SV_STNAME_VALLEY))) goto done; - } else if (z > z2) { - found = M(STR_SV_STNAME_HEIGHTS); - if (HASBIT(free_names, M(STR_SV_STNAME_HEIGHTS))) goto done; + { + uint z = GetTileZ(tile); + uint z2 = GetTileZ(t->xy); + if (z < z2) { + found = M(STR_SV_STNAME_VALLEY); + if (HASBIT(free_names, M(STR_SV_STNAME_VALLEY))) goto done; + } else if (z > z2) { + found = M(STR_SV_STNAME_HEIGHTS); + if (HASBIT(free_names, M(STR_SV_STNAME_HEIGHTS))) goto done; + } } /* check direction compared to town */ @@ -332,13 +295,14 @@ } #undef M -static Station* GetClosestStationFromTile(TileIndex tile, uint threshold, PlayerID owner) +static Station* GetClosestStationFromTile(TileIndex tile) { + uint threshold = 8; Station* best_station = NULL; Station* st; FOR_ALL_STATIONS(st) { - if ((owner == PLAYER_SPECTATOR || st->owner == owner)) { + if (st->facilities == 0 && st->owner == _current_player) { uint cur_dist = DistanceManhattan(tile, st->xy); if (cur_dist < threshold) { @@ -387,9 +351,8 @@ static uint GetAcceptanceMask(const Station *st) { uint mask = 0; - uint i; - - for (i = 0; i != NUM_CARGO; i++) { + + for (uint i = 0; i != NUM_CARGO; i++) { if (st->goods[i].waiting_acceptance & 0x8000) mask |= 1 << i; } return mask; @@ -400,7 +363,7 @@ static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *cargo, StringID msg) { for (uint i = 0; i < num_items; i++) { - SetDParam(i + 1, _cargoc.names_s[cargo[i]]); + SetDParam(i + 1, GetCargo(cargo[i])->name); } SetDParam(0, st->index); @@ -411,35 +374,30 @@ void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad) { - int x,y; - int x1,y1,x2,y2; - int xc,yc; - memset(produced, 0, sizeof(AcceptedCargo)); - x = TileX(tile); - y = TileY(tile); + int x = TileX(tile); + int y = TileY(tile); // expand the region by rad tiles on each side // while making sure that we remain inside the board. - x2 = min(x + w + rad, MapSizeX()); - x1 = max(x - rad, 0); - - y2 = min(y + h + rad, MapSizeY()); - y1 = max(y - rad, 0); + int x2 = min(x + w + rad, MapSizeX()); + int x1 = max(x - rad, 0); + + int y2 = min(y + h + rad, MapSizeY()); + int y1 = max(y - rad, 0); assert(x1 < x2); assert(y1 < y2); assert(w > 0); assert(h > 0); - for (yc = y1; yc != y2; yc++) { - for (xc = x1; xc != x2; xc++) { + for (int yc = y1; yc != y2; yc++) { + for (int xc = x1; xc != x2; xc++) { if (!(IS_INSIDE_1D(xc, x, w) && IS_INSIDE_1D(yc, y, h))) { - GetProducedCargoProc *gpc; TileIndex tile = TileXY(xc, yc); - gpc = _tile_type_procs[GetTileType(tile)]->get_produced_cargo_proc; + GetProducedCargoProc *gpc = _tile_type_procs[GetTileType(tile)]->get_produced_cargo_proc; if (gpc != NULL) { CargoID cargos[2] = { CT_INVALID, CT_INVALID }; @@ -460,37 +418,32 @@ void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad) { - int x,y; - int x1,y1,x2,y2; - int xc,yc; - memset(accepts, 0, sizeof(AcceptedCargo)); - x = TileX(tile); - y = TileY(tile); + int x = TileX(tile); + int y = TileY(tile); // expand the region by rad tiles on each side // while making sure that we remain inside the board. - x2 = min(x + w + rad, MapSizeX()); - y2 = min(y + h + rad, MapSizeY()); - x1 = max(x - rad, 0); - y1 = max(y - rad, 0); + int x2 = min(x + w + rad, MapSizeX()); + int y2 = min(y + h + rad, MapSizeY()); + int x1 = max(x - rad, 0); + int y1 = max(y - rad, 0); assert(x1 < x2); assert(y1 < y2); assert(w > 0); assert(h > 0); - for (yc = y1; yc != y2; yc++) { - for (xc = x1; xc != x2; xc++) { + for (int yc = y1; yc != y2; yc++) { + for (int xc = x1; xc != x2; xc++) { TileIndex tile = TileXY(xc, yc); if (!IsTileType(tile, MP_STATION)) { AcceptedCargo ac; - uint i; GetAcceptedCargo(tile, ac); - for (i = 0; i < lengthof(ac); ++i) accepts[i] += ac[i]; + for (uint i = 0; i < lengthof(ac); ++i) accepts[i] += ac[i]; } } } @@ -518,21 +471,17 @@ // show_msg controls whether to display a message that acceptance was changed. static void UpdateStationAcceptance(Station *st, bool show_msg) { - uint old_acc, new_acc; - const RoadStop *cur_rs; - int i; + // Don't update acceptance for a buoy + if (st->IsBuoy()) return; + ottd_Rectangle rect; - int rad; - AcceptedCargo accepts; - rect.min_x = MapSizeX(); rect.min_y = MapSizeY(); - rect.max_x = rect.max_y = 0; - // Don't update acceptance for a buoy - if (st->IsBuoy()) return; + rect.max_x = 0; + rect.max_y = 0; /* old accepted goods types */ - old_acc = GetAcceptanceMask(st); + uint old_acc = GetAcceptanceMask(st); // Put all the tiles that span an area in the table. if (st->train_tile != 0) { @@ -553,31 +502,30 @@ if (st->dock_tile != 0) MergePoint(&rect, st->dock_tile); - for (cur_rs = st->bus_stops; cur_rs != NULL; cur_rs = cur_rs->next) { - MergePoint(&rect, cur_rs->xy); + for (const RoadStop *rs = st->bus_stops; rs != NULL; rs = rs->next) { + MergePoint(&rect, rs->xy); } - for (cur_rs = st->truck_stops; cur_rs != NULL; cur_rs = cur_rs->next) { - MergePoint(&rect, cur_rs->xy); + for (const RoadStop *rs = st->truck_stops; rs != NULL; rs = rs->next) { + MergePoint(&rect, rs->xy); } - rad = (_patches.modified_catchment) ? FindCatchmentRadius(st) : 4; - // And retrieve the acceptance. + AcceptedCargo accepts; if (rect.max_x >= rect.min_x) { GetAcceptanceAroundTiles( accepts, TileXY(rect.min_x, rect.min_y), rect.max_x - rect.min_x + 1, rect.max_y - rect.min_y + 1, - rad + _patches.modified_catchment ? FindCatchmentRadius(st) : 4 ); } else { memset(accepts, 0, sizeof(accepts)); } // Adjust in case our station only accepts fewer kinds of goods - for (i = 0; i != NUM_CARGO; i++) { + for (uint i = 0; i != NUM_CARGO; i++) { uint amt = min(accepts[i], 15); // Make sure the station can accept the goods type. @@ -589,7 +537,7 @@ } // Only show a message in case the acceptance was actually changed. - new_acc = GetAcceptanceMask(st); + uint new_acc = GetAcceptanceMask(st); if (old_acc == new_acc) return; @@ -638,7 +586,7 @@ static void UpdateStationSignCoord(Station *st) { - StationRect *r = &st->rect; + const StationRect *r = &st->rect; if (r->IsEmpty()) return; // no tiles belong to this station @@ -667,21 +615,18 @@ // Or an error code if it failed. int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station) { - int32 cost = 0, ret; - - Slope tileh; - uint z; + int32 cost = 0; int allowed_z = -1; - int flat_z; - - BEGIN_TILE_LOOP(tile_cur, w, h, tile) + + BEGIN_TILE_LOOP(tile_cur, w, h, tile) { if (MayHaveBridgeAbove(tile_cur) && IsBridgeAbove(tile_cur)) { return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); } if (!EnsureNoVehicle(tile_cur)) return CMD_ERROR; - tileh = GetTileSlope(tile_cur, &z); + uint z; + Slope tileh = GetTileSlope(tile_cur, &z); /* Prohibit building if * 1) The tile is "steep" (i.e. stretches two height levels) @@ -696,7 +641,7 @@ return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); } - flat_z = z; + int flat_z = z; if (tileh != SLOPE_FLAT) { // need to check so the entrance to the station is not pointing at a slope. if ((invalid_dirs&1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) || @@ -732,18 +677,19 @@ } } } else { - ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR); + int32 ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (CmdFailed(ret)) return ret; cost += ret; } - END_TILE_LOOP(tile_cur, w, h, tile) + } END_TILE_LOOP(tile_cur, w, h, tile) return cost; } -static bool CanExpandRailroadStation(Station* st, uint* fin, Axis axis) +static bool CanExpandRailroadStation(const Station* st, uint* fin, Axis axis) { - uint curw = st->trainst_w, curh = st->trainst_h; + uint curw = st->trainst_w; + uint curh = st->trainst_h; TileIndex tile = fin[0]; uint w = fin[1]; uint h = fin[2]; @@ -842,7 +788,7 @@ /** Build railroad station * @param tile_org starting position of station dragging/placement * @param p1 various bitstuffed elements - * - p1 = (bit 0) - orientation (p1 & 1) + * - p1 = (bit 0) - orientation (Axis) * - p1 = (bit 8-15) - number of tracks * - p1 = (bit 16-23) - platform length * @param p2 various bitstuffed elements @@ -852,15 +798,8 @@ */ int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2) { - Station *st; int w_org, h_org; - int32 cost, ret; - StationID est; - int plat_len, numtracks; - Axis axis; - uint finalvalues[3]; - const StationSpec *statspec; - int specindex; + int32 ret; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -869,10 +808,9 @@ if (!ValParamRailtype(p2 & 0xF)) return CMD_ERROR; /* unpack parameters */ - axis = (Axis)(p1 & 1); - numtracks = GB(p1, 8, 8); - plat_len = GB(p1, 16, 8); - /* w = length, h = num_tracks */ + Axis axis = Extract(p1); + uint numtracks = GB(p1, 8, 8); + uint plat_len = GB(p1, 16, 8); if (axis == AXIS_X) { w_org = plat_len; h_org = numtracks; @@ -884,27 +822,25 @@ if (h_org > _patches.station_spread || w_org > _patches.station_spread) return CMD_ERROR; // these values are those that will be stored in train_tile and station_platforms + uint finalvalues[3]; finalvalues[0] = tile_org; finalvalues[1] = w_org; finalvalues[2] = h_org; // Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station) - est = INVALID_STATION; + StationID est = INVALID_STATION; // If DC_EXEC is in flag, do not want to pass it to CheckFlatLandBelow, because of a nice bug // for detail info, see: https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365 ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL); if (CmdFailed(ret)) return ret; - cost = ret + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len; + int32 cost = ret + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len; // Make sure there are no similar stations around us. - st = GetStationAround(tile_org, w_org, h_org, est); + Station *st = GetStationAround(tile_org, w_org, h_org, est); if (st == CHECK_STATIONS_ERR) return CMD_ERROR; // See if there is a deleted station close to us. - if (st == NULL) { - st = GetClosestStationFromTile(tile_org, 8, _current_player); - if (st != NULL && st->facilities) st = NULL; - } + if (st == NULL) st = GetClosestStationFromTile(tile_org); /* In case of new station if DC_EXEC is NOT set we still need to create the station * to test if everything is OK. In this case we need to delete it before return. */ @@ -912,7 +848,7 @@ if (st != NULL) { // Reuse an existing station. - if (st->owner != OWNER_NONE && st->owner != _current_player) + if (st->owner != _current_player) return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION); if (st->train_tile != 0) { @@ -945,8 +881,8 @@ if (GB(p2, 8, 8) >= STAT_CLASS_MAX) return CMD_ERROR; /* Check if we can allocate a custom stationspec to this station */ - statspec = GetCustomStationSpec((StationClassID)GB(p2, 8, 8), GB(p2, 16, 8)); - specindex = AllocateSpecToStation(statspec, st, flags & DC_EXEC); + const StationSpec *statspec = GetCustomStationSpec((StationClassID)GB(p2, 8, 8), GB(p2, 16, 8)); + int specindex = AllocateSpecToStation(statspec, st, flags & DC_EXEC); if (specindex == -1) return CMD_ERROR; if (statspec != NULL) { @@ -1031,14 +967,13 @@ uint w = st->trainst_w; uint h = st->trainst_h; TileIndex tile = st->train_tile; - uint i; restart: // too small? if (w != 0 && h != 0) { // check the left side, x = constant, y changes - for (i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(0, i));) { + for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(0, i));) { // the left side is unused? if (++i == h) { tile += TileDiffXY(1, 0); @@ -1048,7 +983,7 @@ } // check the right side, x = constant, y changes - for (i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(w - 1, i));) { + for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(w - 1, i));) { // the right side is unused? if (++i == h) { w--; @@ -1057,7 +992,7 @@ } // check the upper side, y = constant, x changes - for (i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(i, 0));) { + for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(i, 0));) { // the left side is unused? if (++i == w) { tile += TileDiffXY(0, 1); @@ -1067,7 +1002,7 @@ } // check the lower side, y = constant, x changes - for (i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(i, h - 1));) { + for (uint i = 0; !st->TileBelongsToRailStation(tile + TileDiffXY(i, h - 1));) { // the left side is unused? if (++i == w) { h--; @@ -1091,13 +1026,11 @@ */ int32 CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Station *st; - SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); // make sure the specified tile belongs to the current player, and that it is a railroad station. if (!IsTileType(tile, MP_STATION) || !IsRailwayStation(tile) || !_patches.nonuniform_stations) return CMD_ERROR; - st = GetStationByTile(tile); + Station *st = GetStationByTile(tile); if (_current_player != OWNER_WATER && (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile))) return CMD_ERROR; // if we reached here, it means we can actually delete it. do that. @@ -1130,9 +1063,6 @@ static int32 RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags) { - int w,h; - int32 cost = 0; - /* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */ if (_current_player == OWNER_WATER && _patches.nonuniform_stations) return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION); @@ -1143,11 +1073,12 @@ /* determine width and height of platforms */ tile = st->train_tile; - w = st->trainst_w; - h = st->trainst_h; + int w = st->trainst_w; + int h = st->trainst_h; assert(w != 0 && h != 0); + int32 cost = 0; /* clear all areas of the station */ do { int w_bak = w; @@ -1239,13 +1170,10 @@ */ int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Station *st; - RoadStop *road_stop; - int32 cost; - int32 ret; bool type = HASBIT(p2, 0); bool is_drive_through = HASBIT(p2, 1); bool build_over_road = is_drive_through && IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL; + bool town_owned_road = build_over_road && IsTileOwner(tile, OWNER_TOWN); Owner cur_owner = _current_player; /* Saveguard the parameters */ @@ -1264,23 +1192,20 @@ if (build_over_road) flags ^= DC_AUTO; - if (build_over_road && IsTileOwner(tile, OWNER_TOWN)) _current_player = OWNER_TOWN; - ret = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL); + if (town_owned_road) _current_player = OWNER_TOWN; + int32 ret = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL); _current_player = cur_owner; if (CmdFailed(ret)) return ret; - cost = build_over_road ? 0 : ret; // Don't add cost of clearing road when overbuilding - - st = GetStationAround(tile, 1, 1, INVALID_STATION); + int32 cost = build_over_road ? 0 : ret; // Don't add cost of clearing road when overbuilding + + Station *st = GetStationAround(tile, 1, 1, INVALID_STATION); if (st == CHECK_STATIONS_ERR) return CMD_ERROR; /* Find a station close to us */ - if (st == NULL) { - st = GetClosestStationFromTile(tile, 8, _current_player); - if (st != NULL && st->facilities != 0) st = NULL; - } + if (st == NULL) st = GetClosestStationFromTile(tile); //give us a road stop in the list, and check if something went wrong - road_stop = new RoadStop(tile); + RoadStop *road_stop = new RoadStop(tile); if (road_stop == NULL) { return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); } @@ -1298,7 +1223,7 @@ AutoPtrT st_auto_delete; if (st != NULL) { - if (st->owner != OWNER_NONE && st->owner != _current_player) { + if (st->owner != _current_player) { return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION); } @@ -1334,8 +1259,12 @@ st->rect.BeforeAddTile(tile, StationRect::ADD_TRY); - MakeRoadStop(tile, st->owner, st->index, type ? RoadStop::TRUCK : RoadStop::BUS, is_drive_through, (DiagDirection)p1); - if (is_drive_through & HASBIT(p2, 3)) SetStopBuiltOnTownRoad(tile); + RoadStop::Type rs_type = type ? RoadStop::TRUCK : RoadStop::BUS; + if (is_drive_through) { + MakeDriveThroughRoadStop(tile, st->owner, st->index, rs_type, (Axis)p1, town_owned_road); + } else { + MakeRoadStop(tile, st->owner, st->index, rs_type, (DiagDirection)p1); + } UpdateStationVirtCoordDirty(st); UpdateStationAcceptance(st, false); @@ -1351,14 +1280,14 @@ // Remove a bus station static int32 RemoveRoadStop(Station *st, uint32 flags, TileIndex tile) { - RoadStop **primary_stop; - RoadStop *cur_stop; - bool is_truck = IsTruckStop(tile); - if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) { return CMD_ERROR; } + bool is_truck = IsTruckStop(tile); + + RoadStop **primary_stop; + RoadStop *cur_stop; if (is_truck) { // truck stop primary_stop = &st->truck_stops; cur_stop = GetRoadStopByTile(tile, RoadStop::TRUCK); @@ -1404,21 +1333,15 @@ */ int32 CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Station* st; - bool is_drive_through; - bool is_towns_road = false; - RoadBits road_bits; - int32 ret; - /* Make sure the specified tile is a road stop of the correct type */ if (!IsTileType(tile, MP_STATION) || !IsRoadStop(tile) || (uint32)GetRoadStopType(tile) != p2) return CMD_ERROR; - st = GetStationByTile(tile); + Station *st = GetStationByTile(tile); /* Save the stop info before it is removed */ - is_drive_through = IsDriveThroughStopTile(tile); - road_bits = GetAnyRoadBits(tile); - if (is_drive_through) is_towns_road = GetStopBuiltOnTownRoad(tile); - - ret = RemoveRoadStop(st, flags, tile); + bool is_drive_through = IsDriveThroughStopTile(tile); + RoadBits road_bits = GetAnyRoadBits(tile); + bool is_towns_road = is_drive_through && GetStopBuiltOnTownRoad(tile); + + int32 ret = RemoveRoadStop(st, flags, tile); /* If the stop was a drive-through stop replace the road */ if ((flags & DC_EXEC) && !CmdFailed(ret) && is_drive_through) { @@ -1426,7 +1349,7 @@ Owner cur_owner = _current_player; if (is_towns_road) { - index = ClosestTownFromTile(tile, _patches.dist_local_authority)->index; + index = ClosestTownFromTile(tile, (uint)-1)->index; _current_player = OWNER_TOWN; } DoCommand(tile, road_bits, index, DC_EXEC, CMD_BUILD_ROAD); @@ -1535,13 +1458,7 @@ */ int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Town *t; - Station *st; - int32 cost; - int32 ret; - int w, h; bool airport_upgrade = true; - const AirportFTAClass* afc; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -1551,11 +1468,12 @@ if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR; - t = ClosestTownFromTile(tile, (uint)-1); + Town *t = ClosestTownFromTile(tile, (uint)-1); /* Check if local auth refuses a new airport */ { uint num = 0; + const Station *st; FOR_ALL_STATIONS(st) { if (st->town == t && st->facilities&FACIL_AIRPORT && st->airport_type != AT_OILRIG) num++; @@ -1566,22 +1484,19 @@ } } - afc = GetAirport(p1); - w = afc->size_x; - h = afc->size_y; - - ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL); + const AirportFTAClass *afc = GetAirport(p1); + int w = afc->size_x; + int h = afc->size_y; + + int32 ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL); if (CmdFailed(ret)) return ret; - cost = ret; - - st = GetStationAround(tile, w, h, INVALID_STATION); + int32 cost = ret; + + Station *st = GetStationAround(tile, w, h, INVALID_STATION); if (st == CHECK_STATIONS_ERR) return CMD_ERROR; /* Find a station close to us */ - if (st == NULL) { - st = GetClosestStationFromTile(tile, 8, _current_player); - if (st != NULL && st->facilities) st = NULL; - } + if (st == NULL) st = GetClosestStationFromTile(tile); if (w > _patches.station_spread || h > _patches.station_spread) { _error_message = STR_306C_STATION_TOO_SPREAD_OUT; @@ -1593,7 +1508,7 @@ AutoPtrT st_auto_delete; if (st != NULL) { - if (st->owner != OWNER_NONE && st->owner != _current_player) + if (st->owner != _current_player) return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION); if (!st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TEST)) return CMD_ERROR; @@ -1618,10 +1533,11 @@ st->sign.width_1 = 0; - // if airport type equals Heliport then generate - // type 5 name, which is heliport, otherwise airport names (1) - if (!GenerateStationName(st, tile, (p1 == AT_HELIPORT)||(p1 == AT_HELIDEPOT)||(p1 == AT_HELISTATION) ? 5 : 1)) + /* If only helicopters may use the airport generate a helicopter related (5) + * station name, otherwise generate a normal airport name (1) */ + if (!GenerateStationName(st, tile, !(afc->flags & AirportFTAClass::AIRPLANES) ? 5 : 1)) { return CMD_ERROR; + } } cost += _price.build_airport * w * h; @@ -1664,20 +1580,16 @@ static int32 RemoveAirport(Station *st, uint32 flags) { - TileIndex tile; - int w,h; - int32 cost; - if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR; - tile = st->airport_tile; + TileIndex tile = st->airport_tile; const AirportFTAClass *afc = st->Airport(); - w = afc->size_x; - h = afc->size_y; - - cost = w * h * _price.remove_airport; + int w = afc->size_x; + int h = afc->size_y; + + int32 cost = w * h * _price.remove_airport; BEGIN_TILE_LOOP(tile_cur, w, h, tile) { if (!EnsureNoVehicle(tile_cur)) return CMD_ERROR; @@ -1689,9 +1601,7 @@ } END_TILE_LOOP(tile_cur, w,h,tile) if (flags & DC_EXEC) { - uint i; - - for (i = 0; i < afc->nof_depots; ++i) { + for (uint i = 0; i < afc->nof_depots; ++i) { DeleteWindowById( WC_VEHICLE_DEPOT, tile + ToTileIndexDiff(afc->airport_depots[i]) ); @@ -1716,14 +1626,12 @@ */ int32 CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Station *st; - SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); if (!IsClearWaterTile(tile) || tile == 0) return_cmd_error(STR_304B_SITE_UNSUITABLE); /* allocate and initialize new station */ - st = new Station(tile); + Station *st = new Station(tile); if (st == NULL) return CMD_ERROR; /* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */ @@ -1776,12 +1684,10 @@ static int32 RemoveBuoy(Station *st, uint32 flags) { - TileIndex tile; - /* XXX: strange stuff */ if (!IsValidPlayer(_current_player)) return_cmd_error(INVALID_STRING_ID); - tile = st->dock_tile; + TileIndex tile = st->dock_tile; if (CheckShipsOnBuoy(st)) return_cmd_error(STR_BUOY_IS_IN_USE); if (!EnsureNoVehicle(tile)) return CMD_ERROR; @@ -1827,13 +1733,11 @@ */ int32 CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - TileIndex tile_cur; - DiagDirection direction; int32 cost; - Station *st; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); + DiagDirection direction; switch (GetTileSlope(tile, NULL)) { case SLOPE_SW: direction = DIAGDIR_NE; break; case SLOPE_SE: direction = DIAGDIR_NW; break; @@ -1844,14 +1748,10 @@ if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR; - if (!EnsureNoVehicle(tile)) return CMD_ERROR; - cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (CmdFailed(cost)) return CMD_ERROR; - tile_cur = tile + TileOffsByDiagDir(direction); - - if (!EnsureNoVehicle(tile_cur)) return CMD_ERROR; + TileIndex tile_cur = tile + TileOffsByDiagDir(direction); if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur, NULL) != SLOPE_FLAT) { return_cmd_error(STR_304B_SITE_UNSUITABLE); @@ -1866,23 +1766,20 @@ } /* middle */ - st = GetStationAround( + Station *st = GetStationAround( tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]), _dock_w_chk[direction], _dock_h_chk[direction], INVALID_STATION); if (st == CHECK_STATIONS_ERR) return CMD_ERROR; /* Find a station close to us */ - if (st == NULL) { - st = GetClosestStationFromTile(tile, 8, _current_player); - if (st!=NULL && st->facilities) st = NULL; - } + if (st == NULL) st = GetClosestStationFromTile(tile); /* In case of new station if DC_EXEC is NOT set we still need to create the station * to test if everything is OK. In this case we need to delete it before return. */ AutoPtrT st_auto_delete; if (st != NULL) { - if (st->owner != OWNER_NONE && st->owner != _current_player) + if (st->owner != _current_player) return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION); if (!st->rect.BeforeAddRect(tile, _dock_w_chk[direction], _dock_h_chk[direction], StationRect::ADD_TEST)) return CMD_ERROR; @@ -1927,13 +1824,10 @@ static int32 RemoveDock(Station *st, uint32 flags) { - TileIndex tile1; - TileIndex tile2; - if (!CheckOwnership(st->owner)) return CMD_ERROR; - tile1 = st->dock_tile; - tile2 = tile1 + TileOffsByDiagDir(GetDockDirection(tile1)); + TileIndex tile1 = st->dock_tile; + TileIndex tile2 = tile1 + TileOffsByDiagDir(GetDockDirection(tile1)); if (!EnsureNoVehicle(tile1)) return CMD_ERROR; if (!EnsureNoVehicle(tile2)) return CMD_ERROR; @@ -1969,7 +1863,6 @@ static void DrawTile_Station(TileInfo *ti) { - const DrawTileSeqStruct *dtss; const DrawTileSprites *t = NULL; RailType railtype = GetRailType(ti->tile); const RailtypeInfo *rti = GetRailTypeInfo(railtype); @@ -1977,9 +1870,8 @@ const Station *st = NULL; const StationSpec *statspec = NULL; PlayerID owner = GetTileOwner(ti->tile); - SpriteID image; + SpriteID palette; - if (IsValidPlayer(owner)) { palette = PLAYER_SPRITE_COLOR(owner); } else { @@ -2017,7 +1909,7 @@ if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationGfx(ti->tile)]; - image = t->ground_sprite; + SpriteID image = t->ground_sprite; if (HASBIT(image, SPRITE_MODIFIER_USE_OFFSET)) { image += GetCustomStationGroundRelocation(statspec, st, ti->tile); image += rti->custom_ground_offset; @@ -2033,9 +1925,8 @@ if (IsBuoyTile(ti->tile) && (ti->z != 0 || !IsTileOwner(ti->tile, OWNER_WATER))) DrawCanalWater(ti->tile); + const DrawTileSeqStruct *dtss; foreach_draw_tile_seq(dtss, t->seq) { - SpriteID pal; - image = dtss->image; if (relocation == 0 || HASBIT(image, SPRITE_MODIFIER_USE_OFFSET)) { image += rti->total_offset; @@ -2043,6 +1934,7 @@ image += relocation; } + SpriteID pal; if (_display_opt & DO_TRANS_BUILDINGS) { SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); pal = PALETTE_TO_TRANSPARENT; @@ -2067,18 +1959,14 @@ void StationPickerDrawSprite(int x, int y, RailType railtype, int image) { - SpriteID pal, img; - const DrawTileSeqStruct *dtss; - const DrawTileSprites *t; const RailtypeInfo *rti = GetRailTypeInfo(railtype); - - pal = PLAYER_SPRITE_COLOR(_local_player); - - t = &_station_display_datas[image]; - - img = t->ground_sprite; + SpriteID pal = PLAYER_SPRITE_COLOR(_local_player); + const DrawTileSprites *t = &_station_display_datas[image]; + + SpriteID img = t->ground_sprite; DrawSprite(img + rti->total_offset, HASBIT(img, PALETTE_MODIFIER_COLOR) ? pal : PAL_NONE, x, y); + const DrawTileSeqStruct *dtss; foreach_draw_tile_seq(dtss, t->seq) { Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z); DrawSprite(dtss->image + rti->total_offset, pal, x + pt.x, y + pt.y); @@ -2102,11 +1990,10 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td) { - StringID str; - td->owner = GetTileOwner(tile); td->build_date = GetStationByTile(tile)->build_date; + StringID str; switch (GetStationType(tile)) { default: NOT_REACHED(); case STATION_RAIL: str = STR_305E_RAILROAD_STATION; break; @@ -2200,9 +2087,8 @@ }; StationGfx gfx = GetStationGfx(tile); - const AnimData* i; - - for (i = data; i != endof(data); i++) { + + for (const AnimData *i = data; i != endof(data); i++) { if (i->from <= gfx && gfx <= i->to) { if ((_tick_counter & i->delay) == 0) { SetStationGfx(tile, gfx < i->to ? gfx + 1 : i->from); @@ -2244,7 +2130,7 @@ x &= 0xF; y &= 0xF; - if (DiagDirToAxis(dir) != AXIS_X) intswap(x, y); + if (DiagDirToAxis(dir) != AXIS_X) Swap(x, y); if (y == TILE_SIZE / 2) { if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x; if (x == 12) return VETSB_ENTERED_STATION | (station_id << VETS_STATION_ID_OFFSET); /* enter station */ @@ -2260,7 +2146,7 @@ } } } else if (v->type == VEH_Road) { - if (v->u.road.state < RVSB_IN_ROAD_STOP && v->u.road.frame == 0) { + if (v->u.road.state < RVSB_IN_ROAD_STOP && !IsReversingRoadTrackdir((Trackdir)v->u.road.state) && v->u.road.frame == 0) { if (IsRoadStop(tile)) { /* Attempt to allocate a parking bay in a road stop */ RoadStop *rs = GetRoadStopByTile(tile, GetRoadStopType(tile)); @@ -2317,22 +2203,18 @@ static void UpdateStationRating(Station *st) { - GoodsEntry *ge; - int rating; - StationID index; - int waiting; bool waiting_changed = false; byte_inc_sat(&st->time_since_load); byte_inc_sat(&st->time_since_unload); - ge = st->goods; + GoodsEntry *ge = st->goods; do { if (ge->enroute_from != INVALID_STATION) { byte_inc_sat(&ge->enroute_time); byte_inc_sat(&ge->days_since_pickup); - rating = 0; + int rating = 0; { int b = ge->last_speed; @@ -2361,15 +2243,13 @@ (rating += 35, true); } - { - waiting = GB(ge->waiting_acceptance, 0, 12); - (rating -= 90, waiting > 1500) || - (rating += 55, waiting > 1000) || - (rating += 35, waiting > 600) || - (rating += 10, waiting > 300) || - (rating += 20, waiting > 100) || - (rating += 10, true); - } + int waiting = GB(ge->waiting_acceptance, 0, 12); + (rating -= 90, waiting > 1500) || + (rating += 55, waiting > 1000) || + (rating += 35, waiting > 600) || + (rating += 10, waiting > 300) || + (rating += 20, waiting > 100) || + (rating += 10, true); { int or_ = ge->rating; // old rating @@ -2399,8 +2279,7 @@ } } while (++ge != endof(st->goods)); - index = st->index; - + StationID index = st->index; if (waiting_changed) { InvalidateWindow(WC_STATION_VIEW, index); } else { @@ -2411,11 +2290,9 @@ /* called for every station each tick */ static void StationHandleSmallTick(Station *st) { - byte b; - if (st->facilities == 0) return; - b = st->delete_ctr + 1; + byte b = st->delete_ctr + 1; if (b >= 185) b = 0; st->delete_ctr = b; @@ -2424,19 +2301,15 @@ void OnTick_Station(void) { - uint i; - Station *st; - if (_game_mode == GM_EDITOR) return; - i = _station_tick_ctr; + uint i = _station_tick_ctr; if (++_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0; if (IsValidStationID(i)) StationHandleBigTick(GetStation(i)); - FOR_ALL_STATIONS(st) { - StationHandleSmallTick(st); - } + Station *st; + FOR_ALL_STATIONS(st) StationHandleSmallTick(st); } void StationMonthlyLoop(void) @@ -2451,9 +2324,7 @@ FOR_ALL_STATIONS(st) { if (st->owner == owner && DistanceManhattan(tile, st->xy) <= radius) { - uint i; - - for (i = 0; i != NUM_CARGO; i++) { + for (uint i = 0; i != NUM_CARGO; i++) { GoodsEntry* ge = &st->goods[i]; if (ge->enroute_from != INVALID_STATION) { @@ -2484,15 +2355,12 @@ */ int32 CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - StringID str; - Station *st; - if (!IsValidStationID(p1) || _cmd_text[0] == '\0') return CMD_ERROR; - st = GetStation(p1); + Station *st = GetStation(p1); if (!CheckOwnership(st->owner)) return CMD_ERROR; - str = AllocateNameUnique(_cmd_text, 6); + StringID str = AllocateNameUnique(_cmd_text, 6); if (str == 0) return CMD_ERROR; if (flags & DC_EXEC) { @@ -2514,18 +2382,12 @@ uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount) { Station* around[8]; - uint i; - uint moved; - uint best_rating, best_rating2; - Station *st1, *st2; - uint t; - int rad = 0; + + for (uint i = 0; i < lengthof(around); i++) around[i] = NULL; + int w_prod; //width and height of the "producer" of the cargo int h_prod; int max_rad; - - for (i = 0; i < lengthof(around); i++) around[i] = NULL; - if (_patches.modified_catchment) { w_prod = w; h_prod = h; @@ -2541,14 +2403,12 @@ } BEGIN_TILE_LOOP(cur_tile, w, h, tile - TileDiffXY(max_rad, max_rad)) - Station* st; - cur_tile = TILE_MASK(cur_tile); if (!IsTileType(cur_tile, MP_STATION)) continue; - st = GetStationByTile(cur_tile); - - for (i = 0; i != lengthof(around); i++) { + Station *st = GetStationByTile(cur_tile); + + for (uint i = 0; i != lengthof(around); i++) { if (around[i] == NULL) { if (!st->IsBuoy() && (st->town->exclusive_counter == 0 || st->town->exclusivity == st->owner) && // check exclusive transport rights @@ -2556,9 +2416,6 @@ (!_patches.selectgoods || st->goods[type].last_speed > 0) && // if last_speed is 0, no vehicle has been there. ((st->facilities & ~FACIL_BUS_STOP) != 0 || type == CT_PASSENGERS) && // if we have other fac. than a bus stop, or the cargo is passengers ((st->facilities & ~FACIL_TRUCK_STOP) != 0 || type != CT_PASSENGERS)) { // if we have other fac. than a cargo bay or the cargo is not passengers - int x_dist; - int y_dist; - if (_patches.modified_catchment) { // min and max coordinates of the producer relative const int x_min_prod = 9; @@ -2566,27 +2423,26 @@ const int y_min_prod = 9; const int y_max_prod = 8 + h_prod; - rad = FindCatchmentRadius(st); - - x_dist = min(w_cur - x_min_prod, x_max_prod - w_cur); + int rad = FindCatchmentRadius(st); + + int x_dist = min(w_cur - x_min_prod, x_max_prod - w_cur); if (w_cur < x_min_prod) { x_dist = x_min_prod - w_cur; } else if (w_cur > x_max_prod) { x_dist = w_cur - x_max_prod; } - y_dist = min(h_cur - y_min_prod, y_max_prod - h_cur); + int y_dist = min(h_cur - y_min_prod, y_max_prod - h_cur); if (h_cur < y_min_prod) { y_dist = y_min_prod - h_cur; } else if (h_cur > y_max_prod) { y_dist = h_cur - y_max_prod; } - } else { - x_dist = 0; - y_dist = 0; + + if (x_dist > rad || y_dist > rad) break; } - if (x_dist <= rad && y_dist <= rad) around[i] = st; + around[i] = st; } break; } else if (around[i] == st) { @@ -2600,16 +2456,18 @@ if (around[1] == NULL) { /* only one station around */ - moved = (amount * around[0]->goods[type].rating >> 8) + 1; + uint moved = (amount * around[0]->goods[type].rating >> 8) + 1; UpdateStationWaiting(around[0], type, moved); return moved; } /* several stations around, find the two with the highest rating */ - st2 = st1 = NULL; - best_rating = best_rating2 = 0; - - for (i = 0; i != lengthof(around) && around[i] != NULL; i++) { + Station *st1 = NULL; + Station *st2 = NULL; + uint best_rating = 0; + uint best_rating2 = 0; + + for (uint i = 0; i != lengthof(around) && around[i] != NULL; i++) { if (around[i]->goods[type].rating >= best_rating) { best_rating2 = best_rating; st2 = st1; @@ -2630,9 +2488,9 @@ best_rating2 >>= 1; /* amount given to station 1 */ - t = (best_rating * (amount + 1)) / (best_rating + best_rating2); - - moved = 0; + uint t = (best_rating * (amount + 1)) / (best_rating + best_rating2); + + uint moved = 0; if (t != 0) { moved = t * best_rating / 256 + 1; amount -= t; @@ -2650,7 +2508,6 @@ void BuildOilRig(TileIndex tile) { - uint j; Station *st = new Station(); if (st == NULL) { @@ -2684,7 +2541,7 @@ st->facilities = FACIL_AIRPORT | FACIL_DOCK; st->build_date = _date; - for (j = 0; j != NUM_CARGO; j++) { + for (uint j = 0; j != NUM_CARGO; j++) { st->goods[j].waiting_acceptance = 0; st->goods[j].days_since_pickup = 0; st->goods[j].enroute_from = INVALID_STATION; @@ -2724,14 +2581,33 @@ RebuildStationLists(); InvalidateWindowClasses(WC_STATION_LIST); } else { - DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); + if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile)) { + /* For a drive-through stop on a town-owned road remove the stop and replace the road */ + DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? RoadStop::TRUCK : RoadStop::BUS, DC_EXEC, CMD_REMOVE_ROAD_STOP); + } else { + DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); + } } } +/** + * Check if a drive-through road stop tile can be cleared. + * Road stops built on town-owned roads check the conditions + * that would allow clearing of the original road. + * @param tile road stop tile to check + * @return true if the road can be cleared + */ +static bool CanRemoveRoadWithStop(TileIndex tile) +{ + /* The road can always be cleared if it was not a town-owned road */ + if (!GetStopBuiltOnTownRoad(tile)) return true; + + bool edge_road; + return CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile), OWNER_TOWN, &edge_road); +} + static int32 ClearTile_Station(TileIndex tile, byte flags) { - Station *st; - if (flags & DC_AUTO) { switch (GetStationType(tile)) { case STATION_RAIL: return_cmd_error(STR_300B_MUST_DEMOLISH_RAILROAD); @@ -2746,17 +2622,17 @@ } } - st = GetStationByTile(tile); + Station *st = GetStationByTile(tile); switch (GetStationType(tile)) { case STATION_RAIL: return RemoveRailroadStation(st, tile, flags); case STATION_AIRPORT: return RemoveAirport(st, flags); case STATION_TRUCK: - if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile)) + if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile)) return_cmd_error(STR_3047_MUST_DEMOLISH_TRUCK_STATION); return RemoveRoadStop(st, flags, tile); case STATION_BUS: - if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile)) + if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile)) return_cmd_error(STR_3046_MUST_DEMOLISH_BUS_STATION); return RemoveRoadStop(st, flags, tile); case STATION_BUOY: return RemoveBuoy(st, flags); @@ -2784,24 +2660,15 @@ void AfterLoadStations(void) { + /* Update the speclists of all stations to point to the currently loaded custom stations. */ Station *st; - uint i; - TileIndex tile; - - /* Update the speclists of all stations to point to the currently loaded custom stations. */ FOR_ALL_STATIONS(st) { - for (i = 0; i < st->num_specs; i++) { + for (uint i = 0; i < st->num_specs; i++) { if (st->speclist[i].grfid == 0) continue; st->speclist[i].spec = GetCustomStationSpecByGrf(st->speclist[i].grfid, st->speclist[i].localidx); } } - - for (tile = 0; tile < MapSize(); tile++) { - if (GetTileType(tile) != MP_STATION) continue; - st = GetStationByTile(tile); - st->rect.BeforeAddTile(tile, StationRect::ADD_FORCE); - } } @@ -2920,10 +2787,8 @@ static void SaveLoad_STNS(Station *st) { - uint i; - SlObject(st, _station_desc); - for (i = 0; i != NUM_CARGO; i++) { + for (uint i = 0; i != NUM_CARGO; i++) { SlObject(&st->goods[i], _goods_desc); /* In older versions, enroute_from had 0xFF as INVALID_STATION, is now 0xFFFF */ @@ -2942,7 +2807,9 @@ if (st->num_specs != 0) { /* Allocate speclist memory when loading a game */ if (st->speclist == NULL) st->speclist = CallocT(st->num_specs); - for (i = 0; i < st->num_specs; i++) SlObject(&st->speclist[i], _station_speclist_desc); + for (uint i = 0; i < st->num_specs; i++) { + SlObject(&st->speclist[i], _station_speclist_desc); + } } } @@ -2969,7 +2836,7 @@ uint w = GB(st->trainst_w, 4, 4); uint h = GB(st->trainst_w, 0, 4); - if (GetRailStationAxis(st->train_tile) == AXIS_Y) uintswap(w, h); + if (GetRailStationAxis(st->train_tile) != AXIS_X) Swap(w, h); st->trainst_w = w; st->trainst_h = h; } @@ -3004,5 +2871,3 @@ { 'STNS', Save_STNS, Load_STNS, CH_ARRAY }, { 'ROAD', Save_ROADSTOP, Load_ROADSTOP, CH_ARRAY | CH_LAST}, }; - - diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/station_gui.cpp --- a/src/station_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/station_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -20,6 +20,7 @@ #include "vehicle.h" #include "table/sprites.h" #include "helpers.hpp" +#include "cargotype.h" enum StationListWidgets { STATIONLIST_WIDGET_CLOSEBOX = 0, @@ -57,7 +58,10 @@ * @param rating ratings data for that particular cargo */ static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating) { - int colour = _cargo_colours[type]; + const CargoSpec *cs = GetCargo(type); + if (!cs->IsValid()) return; + + int colour = cs->rating_colour; uint w = (minu(amount, 576) + 5) / 36; /* Draw total cargo (limited) on station (fits into 16 pixels) */ @@ -73,7 +77,7 @@ } } - DrawString(x + 1, y, _cargoc.names_short[type], 0x10); + DrawString(x + 1, y, cs->abbrev, 0x10); /* Draw green/red ratings bar (fits into 14 pixels) */ y += 8; @@ -321,8 +325,11 @@ for (i = 0; i < NUM_CARGO; i++) { cg_ofst = w->IsWidgetLowered(i + STATIONLIST_WIDGET_CARGOSTART) ? 2 : 1; - GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, _cargo_colours[i]); - DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, _cargoc.names_short[i], 0x10); + const CargoSpec *cs = GetCargo(i); + if (cs->IsValid()) { + GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour); + DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, cs->abbrev, 0x10); + } x += 14; } @@ -654,7 +661,7 @@ int cur_x = x; num = min(num, 23); do { - DrawSprite(_cargoc.sprites[i], PAL_NONE, cur_x, y); + DrawSprite(GetCargo(i)->sprite, PAL_NONE, cur_x, y); cur_x += 10; } while (--num); } @@ -699,7 +706,7 @@ *b++ = ','; *b++ = ' '; } - b = InlineString(b, _cargoc.names_s[i]); + b = InlineString(b, GetCargo(i)->name); } } @@ -714,7 +721,7 @@ y = 77; for (i = 0; i != NUM_CARGO; i++) { if (st->goods[i].enroute_from != INVALID_STATION) { - SetDParam(0, _cargoc.names_s[i]); + SetDParam(0, GetCargo(i)->name); SetDParam(2, st->goods[i].rating * 101 >> 8); SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5)); DrawString(8, y, STR_303D, 0); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/station_map.h --- a/src/station_map.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/station_map.h Wed Feb 28 00:33:40 2007 +0000 @@ -169,11 +169,6 @@ return HASBIT(_m[t].m6, 3); } -static inline void SetStopBuiltOnTownRoad(TileIndex t) -{ - assert(IsDriveThroughStopTile(t)); - SETBIT(_m[t].m6, 3); -} /** * Gets the direction the road stop entrance points towards. @@ -312,13 +307,15 @@ SetRailType(t, rt); } -static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, bool is_drive_through, DiagDirection d) +static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, DiagDirection d) { - if (is_drive_through) { - MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT) + d); - } else { - MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE : GFX_TRUCK_BASE) + d); - } + MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE : GFX_TRUCK_BASE) + d); +} + +static inline void MakeDriveThroughRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, Axis a, bool on_town_road) +{ + MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT) + a); + SB(_m[t].m6, 3, 1, on_town_road); } static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section) diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/stdafx.h --- a/src/stdafx.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/stdafx.h Wed Feb 28 00:33:40 2007 +0000 @@ -234,23 +234,12 @@ #endif #ifndef __BEOS__ - -/* some platforms use 4 bytes bool in C++ - * C bool has to be the same */ -# ifndef __cplusplus -# ifdef FOUR_BYTE_BOOL - typedef unsigned long bool; -# else /* FOUR_BYTE_BOOL */ - typedef unsigned char bool; -# endif /* FOUR_BYTE_BOOL */ -# endif /* __cplusplus */ - typedef signed char int8; typedef signed short int16; typedef signed int int32; typedef signed __int64 int64; typedef unsigned __int64 uint64; -#endif /* __BEOS__ */ +#endif /* !__BEOS__ */ #if defined(ARM) || defined(__arm__) || defined(__alpha__) # define OTTD_ALIGNMENT @@ -289,24 +278,11 @@ # define PERSONAL_DIR "" #endif -#ifndef __cplusplus -# ifndef __BEOS__ - enum { - false = 0, - true = 1, - }; -# endif -#endif /* __cplusplus */ - /* Compile time assertions */ #ifdef __OS2__ # define assert_compile(expr) #else -# ifdef __cplusplus -# define assert_compile(expr) extern "C" void __ct_assert__(int a[1 - 2 * !(expr)]) -# else /* __cplusplus */ -# define assert_compile(expr) void __ct_assert__(int a[1 - 2 * !(expr)]) -# endif /* !__cplusplus */ +# define assert_compile(expr) extern "C" void __ct_assert__(int a[1 - 2 * !(expr)]) #endif /* __OS2__ */ assert_compile(sizeof(uint32) == 4); @@ -317,16 +293,10 @@ #define endof(x) (&x[lengthof(x)]) #define lastof(x) (&x[lengthof(x) - 1]) -#ifdef offsetof -# undef offsetof -#endif - -#ifndef __cplusplus -# define offsetof(s,m) (size_t)&(((s *)0)->m) -#else /* __cplusplus */ -# define cpp_offsetof(s,m) (((size_t)&reinterpret_cast((((s*)(char*)8)->m))) - 8) +#define cpp_offsetof(s,m) (((size_t)&reinterpret_cast((((s*)(char*)8)->m))) - 8) +#ifndef offsetof # define offsetof(s,m) cpp_offsetof(s, m) -#endif /* __cplusplus */ +#endif /* offsetof */ /* take care of some name clashes on MacOS */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/strings.cpp --- a/src/strings.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/strings.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -17,20 +17,15 @@ #include "industry.h" #include "variables.h" #include "newgrf_text.h" -#include "table/landscape_const.h" #include "table/control_codes.h" #include "music.h" #include "date.h" #include "industry.h" #include "helpers.hpp" +#include "cargotype.h" -#ifdef WIN32 /* for opendir/readdir/closedir */ # include "fios.h" -#else -# include -# include -#endif /* WIN32 */ char _userstring[128]; @@ -566,7 +561,7 @@ // Short description of cargotypes. Layout: // 8-bit = cargo type // 16-bit = cargo count - StringID cargo_str = _cargo_types_base_values[_opt_ptr->landscape].units_volume[GetInt32(&argv)]; + StringID cargo_str = GetCargo(GetInt32(&argv))->units_volume; switch (cargo_str) { case STR_TONS: { int32 args[1]; @@ -690,7 +685,7 @@ // 8bit - cargo type // 16-bit - cargo count CargoID cargo = GetInt32(&argv); - StringID cargo_str = (cargo == CT_INVALID) ? (StringID)STR_8838_N_A : _cargoc.names_long[cargo]; + StringID cargo_str = (cargo == CT_INVALID) ? (StringID)STR_8838_N_A : GetCargo(cargo)->quantifier; buff = GetStringWithArgs(buff, cargo_str, argv++, last); break; } @@ -1164,7 +1159,7 @@ struct dirent *dirent; int num = 0; - dir = opendir(_paths.lang_dir); + dir = ttd_opendir(_paths.lang_dir); if (dir != NULL) { while ((dirent = readdir(dir)) != NULL) { const char *d_name = FS2OTTD(dirent->d_name); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/table/animcursors.h --- a/src/table/animcursors.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/table/animcursors.h Wed Feb 28 00:33:40 2007 +0000 @@ -5,9 +5,7 @@ * Animated cursors consist of the number of sprites that are * displayed in a round-robin manner. Each sprite also has a time * associated that indicates how many ticks the corresponding sprite - * is to be displayed. Currently all this information is recorded in a single - * array. @todo This should be converted into an array of structs on the long run - * All these arrays end up in an array of pointers called _animcursors. + * is to be displayed. */ /** Creates two array entries that define one @@ -15,15 +13,15 @@ * @param Sprite The Sprite to be displayed * @param display_time The Number of ticks to display the sprite */ -#define ANIM_CURSOR_LINE(Sprite, display_time) Sprite, display_time, +#define ANIM_CURSOR_LINE(Sprite, display_time) { Sprite, display_time }, /** This indicates the termination of the cursor list */ -#define ANIM_CURSOR_END() 0xFFFF +#define ANIM_CURSOR_END() ANIM_CURSOR_LINE(AnimCursor::LAST, 0) /** Animated cursor elements for demolishion */ -static const CursorID _demolish_animcursor[] = { +static const AnimCursor _demolish_animcursor[] = { ANIM_CURSOR_LINE(0x2C0, 8) ANIM_CURSOR_LINE(0x2C1, 8) ANIM_CURSOR_LINE(0x2C2, 8) @@ -33,7 +31,7 @@ /** Animated cursor elements for lower land */ -static const CursorID _lower_land_animcursor[] = { +static const AnimCursor _lower_land_animcursor[] = { ANIM_CURSOR_LINE(0x2BB, 10) ANIM_CURSOR_LINE(0x2BC, 10) ANIM_CURSOR_LINE(0x2BD, 29) @@ -42,7 +40,7 @@ /** Animated cursor elements for raise land */ -static const CursorID _raise_land_animcursor[] = { +static const AnimCursor _raise_land_animcursor[] = { ANIM_CURSOR_LINE(0x2B8, 10) ANIM_CURSOR_LINE(0x2B9, 10) ANIM_CURSOR_LINE(0x2BA, 29) @@ -51,7 +49,7 @@ /** Animated cursor elements for the goto icon */ -static const CursorID _order_goto_animcursor[] = { +static const AnimCursor _order_goto_animcursor[] = { ANIM_CURSOR_LINE(0x2CC, 10) ANIM_CURSOR_LINE(0x2CD, 10) ANIM_CURSOR_LINE(0x2CE, 29) @@ -60,7 +58,7 @@ /** Animated cursor elements for the build signal icon */ -static const CursorID _build_signals_animcursor[] = { +static const AnimCursor _build_signals_animcursor[] = { ANIM_CURSOR_LINE(0x50C, 20) ANIM_CURSOR_LINE(0x50D, 20) ANIM_CURSOR_END() @@ -70,7 +68,7 @@ * definitions we have above. This is the only thing that is * accessed directly from other files */ -static const CursorID * const _animcursors[] = { +static const AnimCursor * const _animcursors[] = { _demolish_animcursor, _lower_land_animcursor, _raise_land_animcursor, diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/table/build_industry.h --- a/src/table/build_industry.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/table/build_industry.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,6 +1,7 @@ /* $Id$ */ - +#ifndef BUILD_INDUSTRY_H +#define BUILD_INDUSTRY_H #define MK(x,y, m) {{x, y}, m} @@ -1460,141 +1461,257 @@ _industry_create_table_3, }; - -#define PAS CT_PASSENGERS - -#define COL CT_COAL -#define RUB CT_RUBBER -#define SUG CT_SUGAR - -#define MAL CT_MAIL - -#define OIL CT_OIL -#define TOY CT_TOYS - -#define LIV CT_LIVESTOCK // Fruit too -#define BAT CT_BATTERIES - -#define GRA CT_GRAIN -#define WHT CT_WHEAT // Maize too -#define TOF CT_TOFFEE - -#define WOD CT_WOOD -#define CLA CT_COLA - -#define IRN CT_IRON_ORE -#define COP CT_COPPER_ORE -#define CCY CT_COTTON_CANDY - -#define STL CT_STEEL -#define PAP CT_PAPER -#define WAT CT_WATER -#define BBL CT_BUBBLES - -#define VAL CT_VALUABLES -#define GLD CT_GOLD // Diamonds too -#define PLC CT_PLASTIC - -#define INV CT_INVALID - -static const CargoID _industry_section_accepts_1[] = { - INV, INV, INV, PAS, INV, INV, INV, INV, - PAS, INV, INV, PAS, PAS, PAS, INV, INV, - INV, INV, INV, INV, INV, INV, INV, PAS, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, PAS, PAS, INV, INV, INV, INV, GRA, - GRA, GRA, GRA, INV, INV, INV, INV, INV, - INV, INV, PAS, PAS, PAS, PAS, PAS, PAS, - PAS, PAS, PAS, PAS, WHT, WHT, WHT, WHT, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, COP, COP, COP, COP, INV, INV, INV, - INV, INV, INV, CCY, CCY, CCY, CCY, INV, - INV, INV, INV, INV, INV, INV, BAT, BAT, - BAT, BAT, BAT, BAT, INV, INV, INV, INV, - INV, INV, INV, INV, BBL, BBL, BBL, BBL, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV -}; - +#define MK(c1, c2, c3, sl) \ + {{c1, c2, c3}, sl} -static const CargoID _industry_section_accepts_2[] = { - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, STL, - STL, STL, STL, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, WOD, WOD, WOD, WOD, INV, INV, INV, - INV, INV, INV, TOF, TOF, TOF, TOF, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV -}; +static const IndustryTileSpec _industry_tile_specs[] = { + /* Coal Mine */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), -static const CargoID _industry_section_accepts_3[] = { - INV, INV, INV, INV, INV, INV, INV, INV, - COL, INV, INV, INV, INV, WOD, INV, INV, - INV, INV, INV, INV, OIL, INV, INV, INV, - PAS, MAL, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, LIV, - LIV, LIV, LIV, PAP, PAP, PAP, PAP, INV, - INV, INV, INV, INV, IRN, IRN, IRN, IRN, - IRN, IRN, VAL, VAL, LIV, LIV, LIV, LIV, - WOD, WOD, WOD, WOD, WOD, WOD, WOD, WOD, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, GLD, GLD, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV, INV, - WAT, RUB, RUB, RUB, RUB, INV, INV, INV, - INV, INV, INV, SUG, SUG, SUG, SUG, INV, - INV, INV, TOY, TOY, TOY, TOY, PLC, PLC, - PLC, PLC, PLC, PLC, INV, INV, INV, INV, - INV, INV, INV, INV, CLA, CLA, CLA, CLA, - INV, INV, INV, INV, INV, INV, INV, INV, - INV, INV, INV, INV, INV, INV, INV -}; + /* Power Station */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_COAL, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), -#undef PAS -#undef COL -#undef RUB -#undef SUG -#undef MAL -#undef OIL -#undef TOY -#undef LIV -#undef BAT -#undef GRA -#undef WHT -#undef TOF -#undef WOD -#undef CLA -#undef IRN -#undef COP -#undef CCY -#undef STL -#undef PAP -#undef WAT -#undef BBL -#undef VAL -#undef GLD -#undef PLC -#undef INV + /* Sawmill */ + MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_WOOD, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Forest Artic, temperate */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Oil refinery */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_OIL, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* oil Rig */ + MK(CT_INVALID, CT_INVALID, CT_PASSENGERS, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_MAIL, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Oil Wells artic, temperate */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Farm tropic, arctic and temperate */ + MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Factory temperate */ + MK(CT_GRAIN, CT_STEEL, CT_LIVESTOCK, SLOPE_STEEP), + MK(CT_GRAIN, CT_STEEL, CT_LIVESTOCK, SLOPE_STEEP), + MK(CT_GRAIN, CT_STEEL, CT_LIVESTOCK, SLOPE_STEEP), + MK(CT_GRAIN, CT_STEEL, CT_LIVESTOCK, SLOPE_STEEP), + + /* Printing works */ + MK(CT_INVALID, CT_INVALID, CT_PAPER, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_PAPER, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_PAPER, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_PAPER, SLOPE_STEEP), + + /* Copper ore mine */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Steel mill */ + MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP), + MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP), + + /* Bank temperate*/ + MK(CT_PASSENGERS, CT_INVALID, CT_VALUABLES, SLOPE_E), + MK(CT_PASSENGERS, CT_INVALID, CT_VALUABLES, SLOPE_S), + + /* Food processing plant, tropic and arctic. CT_MAIZE or CT_WHEAT, CT_LIVESTOCK or CT_FRUIT*/ + MK(CT_MAIZE, CT_INVALID, CT_LIVESTOCK, SLOPE_STEEP), + MK(CT_MAIZE, CT_INVALID, CT_LIVESTOCK, SLOPE_STEEP), + MK(CT_MAIZE, CT_INVALID, CT_LIVESTOCK, SLOPE_STEEP), + MK(CT_MAIZE, CT_INVALID, CT_LIVESTOCK, SLOPE_STEEP), + + /* Paper mill */ + MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP), + + /* Gold mine */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Bank Sub Arctic */ + MK(CT_INVALID, CT_INVALID, CT_GOLD, SLOPE_E), + MK(CT_INVALID, CT_INVALID, CT_GOLD, SLOPE_S), + + /* Diamond mine */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Iron ore Mine */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Fruit plantation */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Rubber plantation */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Water supply */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Water tower */ + MK(CT_INVALID, CT_INVALID, CT_WATER, SLOPE_STEEP), + + /* Factory (sub-tropical) */ + MK(CT_COPPER_ORE, CT_WOOD, CT_RUBBER, SLOPE_STEEP), + MK(CT_COPPER_ORE, CT_WOOD, CT_RUBBER, SLOPE_STEEP), + MK(CT_COPPER_ORE, CT_WOOD, CT_RUBBER, SLOPE_STEEP), + MK(CT_COPPER_ORE, CT_WOOD, CT_RUBBER, SLOPE_STEEP), + + /* Lumber mill */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Candyfloss forest */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Sweet factory */ + MK(CT_COTTON_CANDY, CT_TOFFEE, CT_SUGAR, SLOPE_STEEP), + MK(CT_COTTON_CANDY, CT_TOFFEE, CT_SUGAR, SLOPE_STEEP), + MK(CT_COTTON_CANDY, CT_TOFFEE, CT_SUGAR, SLOPE_STEEP), + MK(CT_COTTON_CANDY, CT_TOFFEE, CT_SUGAR, SLOPE_STEEP), + + /* Batter farm */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Cola wells */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Toy shop */ + MK(CT_INVALID, CT_INVALID, CT_TOYS, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_TOYS, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_TOYS, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_TOYS, SLOPE_STEEP), + + /* Toy factory */ + MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP), + MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP), + MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP), + MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP), + MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP), + MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP), + + /* Plastic Fountain */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Fizzy drink factory */ + MK(CT_BUBBLES, CT_INVALID, CT_COLA, SLOPE_STEEP), + MK(CT_BUBBLES, CT_INVALID, CT_COLA, SLOPE_STEEP), + MK(CT_BUBBLES, CT_INVALID, CT_COLA, SLOPE_STEEP), + MK(CT_BUBBLES, CT_INVALID, CT_COLA, SLOPE_STEEP), + + /* Bubble generator */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Toffee quarry */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + + /* Sugar mine */ + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), + MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP), +}; +#undef MK + +#endif /* BUILD_INDUSTRY_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/table/cargo_const.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/table/cargo_const.h Wed Feb 28 00:33:40 2007 +0000 @@ -0,0 +1,142 @@ +/* $Id$ */ + +/* Table of all default cargo types */ + +#define MK(bt, label, c, e, f, g, h, fr, ks1, ks2, ks3, ks4, ks5, l, m) \ + {bt, label, 0, c, c, e, f, {g, h}, fr, 0, 0, 0, ks1, ks2, ks3, ks4, ks5, l, m} +static const CargoSpec _default_cargo[] = { + MK( 0, 'PASS', 152, 1, 3185, 0, 24, false, + STR_000F_PASSENGERS, STR_002F_PASSENGER, STR_PASSENGERS, STR_QUANTITY_PASSENGERS, STR_ABBREV_PASSENGERS, + SPR_CARGO_PASSENGER, CC_PASSENGERS ), + + MK( 1, 'COAL', 32, 16, 5916, 7, 255, true, + STR_0010_COAL, STR_0030_COAL, STR_TONS, STR_QUANTITY_COAL, STR_ABBREV_COAL, + SPR_CARGO_COAL, CC_BULK ), + + MK( 2, 'MAIL', 15, 4, 4550, 20, 90, false, + STR_0011_MAIL, STR_0031_MAIL, STR_BAGS, STR_QUANTITY_MAIL, STR_ABBREV_MAIL, + SPR_CARGO_MAIL, CC_MAIL ), + + MK( 3, 'OIL_', 174, 16, 4437, 25, 255, true, + STR_0012_OIL, STR_0032_OIL, STR_LITERS, STR_QUANTITY_OIL, STR_ABBREV_OIL, + SPR_CARGO_OIL, CC_LIQUID ), + + MK( 4, 'LVST', 208, 3, 4322, 4, 18, true, + STR_0013_LIVESTOCK, STR_0033_LIVESTOCK, STR_ITEMS, STR_QUANTITY_LIVESTOCK, STR_ABBREV_LIVESTOCK, + SPR_CARGO_LIVESTOCK, CC_PIECE_GOODS ), + + MK( 5, 'GOOD', 194, 8, 6144, 5, 28, true, + STR_0014_GOODS, STR_0034_GOODS, STR_CRATES, STR_QUANTITY_GOODS, STR_ABBREV_GOODS, + SPR_CARGO_GOODS, CC_EXPRESS ), + + MK( 6, 'GRAI', 191, 16, 4778, 4, 40, true, + STR_0015_GRAIN, STR_0035_GRAIN, STR_TONS, STR_QUANTITY_GRAIN, STR_ABBREV_GRAIN, + SPR_CARGO_GRAIN, CC_BULK ), + + MK( 6, 'WHEA', 191, 16, 4778, 4, 40, true, + STR_0022_WHEAT, STR_0042_WHEAT, STR_TONS, STR_QUANTITY_WHEAT, STR_ABBREV_WHEAT, + SPR_CARGO_GRAIN, CC_BULK ), + + MK( 6, 'MAIZ', 191, 6, 4778, 4, 40, true, + STR_001B_MAIZE, STR_003B_MAIZE, STR_TONS, STR_QUANTITY_MAIZE, STR_ABBREV_MAIZE, + SPR_CARGO_GRAIN, CC_BULK ), + + MK( 7, 'WOOD', 84, 16, 5005, 15, 255, true, + STR_0016_WOOD, STR_0036_WOOD, STR_TONS, STR_QUANTITY_WOOD, STR_ABBREV_WOOD, + SPR_CARGO_WOOD, CC_PIECE_GOODS ), + + MK( 8, 'IORE', 184, 16, 5120, 9, 255, true, + STR_0017_IRON_ORE, STR_0037_IRON_ORE, STR_TONS, STR_QUANTITY_IRON_ORE, STR_ABBREV_IRON_ORE, + SPR_CARGO_IRON_ORE, CC_BULK ), + + MK( 9, 'STEL', 10, 16, 5688, 7, 255, true, + STR_0018_STEEL, STR_0038_STEEL, STR_TONS, STR_QUANTITY_STEEL, STR_ABBREV_STEEL, + SPR_CARGO_STEEL, CC_PIECE_GOODS ), + + MK( 10, 'VALU', 202, 2, 7509, 1, 32, true, + STR_0019_VALUABLES, STR_0039_VALUABLES, STR_BAGS, STR_QUANTITY_VALUABLES, STR_ABBREV_VALUABLES, + SPR_CARGO_VALUES_GOLD, CC_ARMOURED ), + + MK( 10, 'GOLD', 202, 8, 7509, 10, 40, true, + STR_0020_GOLD, STR_0040_GOLD, STR_BAGS, STR_QUANTITY_GOLD, STR_ABBREV_GOLD, + SPR_CARGO_VALUES_GOLD, CC_ARMOURED ), + + MK( 10, 'DIAM', 202, 2, 7509, 10, 255, true, + STR_001D_DIAMONDS, STR_003D_DIAMOND, STR_BAGS, STR_QUANTITY_DIAMONDS, STR_ABBREV_DIAMONDS, + SPR_CARGO_DIAMONDS, CC_ARMOURED ), + + MK( 11, 'PAPR', 10, 16, 5688, 7, 60, true, + STR_001F_PAPER, STR_003F_PAPER, STR_TONS, STR_QUANTITY_PAPER, STR_ABBREV_PAPER, + SPR_CARGO_PAPER, CC_PIECE_GOODS ), + + MK( 12, 'FOOD', 48, 16, 5688, 0, 30, true, + STR_001E_FOOD, STR_003E_FOOD, STR_TONS, STR_QUANTITY_FOOD, STR_ABBREV_FOOD, + SPR_CARGO_FOOD, CC_EXPRESS | CC_REFRIGERATED), + + MK( 13, 'FRUT', 208, 6, 4322, 0, 15, true, + STR_001C_FRUIT, STR_003C_FRUIT, STR_TONS, STR_QUANTITY_FRUIT, STR_ABBREV_FRUIT, + SPR_CARGO_FRUIT, CC_BULK | CC_REFRIGERATED), + + MK( 14, 'CORE', 184, 6, 5120, 12, 255, true, + STR_001A_COPPER_ORE, STR_003A_COPPER_ORE, STR_TONS, STR_QUANTITY_COPPER_ORE, STR_ABBREV_COPPER_ORE, + SPR_CARGO_COPPER_ORE, CC_BULK ), + + MK( 15, 'WATR', 10, 6, 5688, 20, 80, true, + STR_0021_WATER, STR_0041_WATER, STR_LITERS, STR_QUANTITY_WATER, STR_ABBREV_WATER, + SPR_CARGO_WATERCOLA, CC_LIQUID ), + + MK( 16, 'RUBR', 32, 6, 5916, 2, 20, true, + STR_0023_RUBBER, STR_0043_RUBBER, STR_LITERS, STR_QUANTITY_RUBBER, STR_ABBREV_RUBBER, + SPR_CARGO_RUBBER, CC_LIQUID ), + + MK( 17, 'SUGR', 32, 16, 5916, 20, 255, true, + STR_0024_SUGAR, STR_0044_SUGAR, STR_TONS, STR_QUANTITY_SUGAR, STR_ABBREV_SUGAR, + SPR_CARGO_SUGAR, CC_BULK ), + + MK( 18, 'TOYS', 174, 2, 4437, 25, 255, true, + STR_0025_TOYS, STR_0045_TOY, STR_NOTHING, STR_QUANTITY_TOYS, STR_ABBREV_TOYS, + SPR_CARGO_TOYS, CC_PIECE_GOODS ), + + MK( 19, 'BATT', 208, 4, 4322, 2, 30, true, + STR_002B_BATTERIES, STR_004B_BATTERY, STR_NOTHING, STR_QUANTITY_BATTERIES, STR_ABBREV_BATTERIES, + SPR_CARGO_BATTERIES, CC_PIECE_GOODS ), + + MK( 20, 'SWET', 194, 5, 6144, 8, 40, true, + STR_0026_CANDY, STR_0046_CANDY, STR_TONS, STR_QUANTITY_SWEETS, STR_ABBREV_SWEETS, + SPR_CARGO_CANDY, CC_EXPRESS ), + + MK( 21, 'TOFF', 191, 16, 4778, 14, 60, true, + STR_002A_TOFFEE, STR_004A_TOFFEE, STR_TONS, STR_QUANTITY_TOFFEE, STR_ABBREV_TOFFEE, + SPR_CARGO_TOFFEE, CC_BULK ), + + MK( 22, 'COLA', 84, 16, 5005, 5, 75, true, + STR_0027_COLA, STR_0047_COLA, STR_LITERS, STR_QUANTITY_COLA, STR_ABBREV_COLA, + SPR_CARGO_WATERCOLA, CC_LIQUID ), + + MK( 23, 'CTCD', 184, 16, 5120, 10, 25, true, + STR_0028_COTTON_CANDY, STR_0048_COTTON_CANDY, STR_TONS, STR_QUANTITY_CANDYFLOSS, STR_ABBREV_CANDYFLOSS, + SPR_CARGO_COTTONCANDY, CC_BULK ), + + MK( 24, 'BUBL', 10, 1, 5688, 20, 80, true, + STR_0029_BUBBLES, STR_0049_BUBBLE, STR_NOTHING, STR_QUANTITY_BUBBLES, STR_ABBREV_BUBBLES, + SPR_CARGO_BUBBLES, CC_PIECE_GOODS ), + + MK( 25, 'PLST', 202, 16, 7509, 30, 255, true, + STR_002C_PLASTIC, STR_004C_PLASTIC, STR_LITERS, STR_QUANTITY_PLASTIC, STR_ABBREV_PLASTIC, + SPR_CARGO_PLASTIC, CC_LIQUID ), + + MK( 26, 'FZDR', 48, 2, 5688, 30, 50, true, + STR_002D_FIZZY_DRINKS, STR_004D_FIZZY_DRINK, STR_NOTHING, STR_QUANTITY_FIZZY_DRINKS, STR_ABBREV_FIZZY_DRINKS, + SPR_CARGO_FIZZYDRINK, CC_PIECE_GOODS ), + +}; + + +/* Table of which cargo types are available in each climate, by default */ +static const CargoLabel _default_climate_cargo[NUM_LANDSCAPE][12] = { + { 'PASS', 'COAL', 'MAIL', 'OIL_', 'LVST', 'GOOD', 'GRAI', 'WOOD', 'IORE', 'STEL', 'VALU', 'VOID', }, + { 'PASS', 'COAL', 'MAIL', 'OIL_', 'LVST', 'GOOD', 'WHEA', 'WOOD', 'VOID', 'PAPR', 'GOLD', 'FOOD', }, + { 'PASS', 'RUBR', 'MAIL', 'OIL_', 'FRUT', 'GOOD', 'MAIZ', 'WOOD', 'CORE', 'WATR', 'DIAM', 'FOOD', }, + { 'PASS', 'SUGR', 'MAIL', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', 'PLST', 'FZDR', }, +}; + diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/table/files.h --- a/src/table/files.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/table/files.h Wed Feb 28 00:33:40 2007 +0000 @@ -59,7 +59,7 @@ { "autorail.grf", { 0xed, 0x44, 0x7f, 0xbb, 0x19, 0x44, 0x48, 0x4c, 0x07, 0x8a, 0xb1, 0xc1, 0x5c, 0x12, 0x3a, 0x60 } }, { "canalsw.grf", { 0x13, 0x9c, 0x98, 0xcf, 0xb8, 0x7c, 0xd7, 0x1f, 0xca, 0x34, 0xa5, 0x6b, 0x65, 0x31, 0xec, 0x0f } }, { "elrailsw.grf", { 0x4f, 0xf9, 0xac, 0x79, 0x50, 0x28, 0x9b, 0xe2, 0x15, 0x30, 0xa8, 0x1e, 0xd5, 0xfd, 0xe1, 0xda } }, - { "openttd.grf", { 0x59, 0x22, 0x19, 0xe0, 0x6e, 0xe7, 0xb6, 0xa3, 0x55, 0x53, 0xcc, 0x9e, 0xbc, 0xaf, 0xcc, 0x83 } }, + { "openttd.grf", { 0x10, 0xc1, 0x68, 0x56, 0x9e, 0x1e, 0x0e, 0x85, 0x9d, 0xf8, 0x53, 0x27, 0x48, 0x7e, 0x17, 0x58 } }, { "trkfoundw.grf", { 0x12, 0x33, 0x3f, 0xa3, 0xd1, 0x86, 0x8b, 0x04, 0x53, 0x18, 0x9c, 0xee, 0xf9, 0x2d, 0xf5, 0x95 } }, { "roadstops.grf", { 0x8c, 0xd9, 0x45, 0x21, 0x28, 0x82, 0x96, 0x45, 0x33, 0x22, 0x7a, 0xb9, 0x0d, 0xf3, 0x67, 0x4a } }, }; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/table/industry_land.h --- a/src/table/industry_land.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/table/industry_land.h Wed Feb 28 00:33:40 2007 +0000 @@ -961,34 +961,6 @@ #undef N -/** - * The indices into this table are the ones as described by - * the enum with GFX_*s in industry_map.h. - */ -static const byte _industry_section_bits[NUM_INDUSTRY_GFXES] = { - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 4, 2, 16, 16, 16, 16, // <- temperate bank - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 4, 2, 16, 16, 16, 16, 16, // <- sub-arctic/sub-tropical bank - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, -}; /** * When true, the tile has to be drawn using the animation diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/table/landscape_const.h --- a/src/table/landscape_const.h Tue Feb 27 23:54:28 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,257 +0,0 @@ -/* $Id$ */ - -#include "sprites.h" - -typedef struct CargoTypesValues { - StringID names[NUM_CARGO]; - StringID units_volume[NUM_CARGO]; - byte weights[NUM_CARGO]; - SpriteID sprites[NUM_CARGO]; - - uint16 initial_cargo_payment[NUM_CARGO]; - byte transit_days_table_1[NUM_CARGO]; - byte transit_days_table_2[NUM_CARGO]; -} CargoTypesValues; - - -static const CargoTypesValues _cargo_types_base_values[4] = { - { - /* normal names */ - { - STR_000F_PASSENGERS, - STR_0010_COAL, - STR_0011_MAIL, - STR_0012_OIL, - STR_0013_LIVESTOCK, - STR_0014_GOODS, - STR_0015_GRAIN, - STR_0016_WOOD, - STR_0017_IRON_ORE, - STR_0018_STEEL, - STR_0019_VALUABLES, - STR_000E, - }, - - { /* normal units of volume */ - STR_PASSENGERS, - STR_TONS, - STR_BAGS, - STR_LITERS, - STR_ITEMS, - STR_CRATES, - STR_TONS, - STR_TONS, - STR_TONS, - STR_TONS, - STR_BAGS, - STR_RES_OTHER - }, - - /* normal weights */ - { - 1, 16, 4, 16, 3, 8, 16, 16, 16, 16, 2, 0, - }, - - /* normal sprites */ - { - SPR_CARGO_PASSENGER, SPR_CARGO_COAL, SPR_CARGO_MAIL, SPR_CARGO_OIL, SPR_CARGO_LIVESTOCK, - SPR_CARGO_GOODS, SPR_CARGO_GRAIN, SPR_CARGO_WOOD, SPR_CARGO_IRON_ORE, SPR_CARGO_STEEL, - SPR_CARGO_VALUES_GOLD, SPR_ASCII_SPACE - }, - - /* normal initial cargo payment */ - { - 3185, 5916, 4550, 4437, 4322, 6144, 4778, 5005, 5120, 5688, 7509, 5688 - }, - - /* normal transit days table 1 */ - { - 0, 7, 20, 25, 4, 5, 4, 15, 9, 7, 1, 0, - }, - - /* normal transit days table 2 */ - { - 24, 255, 90, 255, 18, 28, 40, 255, 255, 255, 32, 30, - }, - }, - - { - /* hilly names */ - { - STR_000F_PASSENGERS, - STR_0010_COAL, - STR_0011_MAIL, - STR_0012_OIL, - STR_0013_LIVESTOCK, - STR_0014_GOODS, - STR_0022_WHEAT, - STR_0016_WOOD, - STR_000E, - STR_001F_PAPER, - STR_0020_GOLD, - STR_001E_FOOD, - }, - - { /* hilly units of volume */ - STR_PASSENGERS, - STR_TONS, - STR_BAGS, - STR_LITERS, - STR_ITEMS, - STR_CRATES, - STR_TONS, - STR_TONS, - STR_RES_OTHER, - STR_TONS, - STR_BAGS, - STR_TONS - }, - - /* hilly weights */ - { - 1, 16, 4, 16, 3, 8, 16, 16, 0, 16, 8, 16 - }, - - /* hilly sprites */ - { - SPR_CARGO_PASSENGER, SPR_CARGO_COAL, SPR_CARGO_MAIL, SPR_CARGO_OIL, SPR_CARGO_LIVESTOCK, - SPR_CARGO_GOODS, SPR_CARGO_GRAIN, SPR_CARGO_WOOD, SPR_ASCII_SPACE, SPR_CARGO_PAPER, - SPR_CARGO_VALUES_GOLD, SPR_CARGO_FOOD - }, - - /* hilly initial cargo payment */ - { - 3185, 5916, 4550, 4437, 4322, 6144, 4778, 5005, 5120, 5461, 5802, 5688 - }, - - /* hilly transit days table 1 */ - { - 0, 7, 20, 25, 4, 5, 4, 15, 9, 7, 10, 0, - }, - - /* hilly transit days table 2 */ - { - 24, 255, 90, 255, 18, 28, 40, 255, 255, 60, 40, 30 - }, - }, - - { - /* desert names */ - { - STR_000F_PASSENGERS, - STR_0023_RUBBER, - STR_0011_MAIL, - STR_0012_OIL, - STR_001C_FRUIT, - STR_0014_GOODS, - STR_001B_MAIZE, - STR_0016_WOOD, - STR_001A_COPPER_ORE, - STR_0021_WATER, - STR_001D_DIAMONDS, - STR_001E_FOOD - }, - - { /* desert units of volume */ - STR_PASSENGERS, - STR_LITERS, - STR_BAGS, - STR_LITERS, - STR_TONS, - STR_CRATES, - STR_TONS, - STR_TONS, - STR_TONS, - STR_LITERS, - STR_BAGS, - STR_TONS - }, - - /* desert weights */ - { - 1, 16, 4, 16, 16, 8, 16, 16, 16, 16, 2, 16, - }, - - /* desert sprites */ - { - SPR_CARGO_PASSENGER, SPR_CARGO_RUBBER, SPR_CARGO_MAIL, SPR_CARGO_OIL, SPR_CARGO_FRUIT, - SPR_CARGO_GOODS, SPR_CARGO_GRAIN, SPR_CARGO_WOOD, SPR_CARGO_COPPER_ORE, SPR_CARGO_WATERCOLA, - SPR_CARGO_DIAMONDS, SPR_CARGO_FOOD - }, - - /* desert initial cargo payment */ - { - 3185, 4437, 4550, 4892, 4209, 6144, 4322, 7964, 4892, 4664, 5802, 5688 - }, - - /* desert transit days table 1 */ - { - 0, 2, 20, 25, 0, 5, 4, 15, 12, 20, 10, 0 - }, - - /* desert transit days table 2 */ - { - 24, 20, 90, 255, 15, 28, 40, 255, 255, 80, 255, 30 - }, - }, - - { - /* candy names */ - { - STR_000F_PASSENGERS, - STR_0024_SUGAR, - STR_0011_MAIL, - STR_0025_TOYS, - STR_002B_BATTERIES, - STR_0026_CANDY, - STR_002A_TOFFEE, - STR_0027_COLA, - STR_0028_COTTON_CANDY, - STR_0029_BUBBLES, - STR_002C_PLASTIC, - STR_002D_FIZZY_DRINKS, - }, - - { /* candy unitrs of volume */ - STR_PASSENGERS, - STR_TONS, - STR_BAGS, - STR_NOTHING, - STR_NOTHING, - STR_TONS, - STR_TONS, - STR_LITERS, - STR_TONS, - STR_NOTHING, - STR_LITERS, - STR_NOTHING - }, - - /* candy weights */ - { - 1, 16, 4, 2, 4, 5, 16, 16, 16, 1, 16, 2 - }, - - /* candy sprites */ - { - SPR_CARGO_PASSENGER, SPR_CARGO_SUGAR, SPR_CARGO_MAIL, SPR_CARGO_TOYS, SPR_CARGO_BATTERIES, - SPR_CARGO_CANDY, SPR_CARGO_TOFFEE, SPR_CARGO_WATERCOLA, SPR_CARGO_COTTONCANDY, SPR_CARGO_BUBBLES, - SPR_CARGO_PLASTIC, SPR_CARGO_FIZZYDRINK - }, - - /* candy initial cargo payment */ - { - 3185, 4437, 4550, 5574, 4322, 6144, 4778, 4892, 5005, 5077, 4664, 6250 - }, - - /* candy transit days table 1 */ - { - 0, 20, 20, 25, 2, 8, 14, 5, 10, 20, 30, 30, - }, - - /* candy transit days table 2 */ - { - 24, 255, 90, 255, 30, 40, 60, 75, 25, 80, 255, 50 - }, - } -}; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/table/namegen.h --- a/src/table/namegen.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/table/namegen.h Wed Feb 28 00:33:40 2007 +0000 @@ -709,17 +709,17 @@ "Bordeaux", "Bayonne", "Montpellier", - "Montelimar", + "Montélimar", "Valence", "Digne", "Nice", "Cannes", "St. Tropez", - "Marseilles", + "Marseille", "Narbonne", "Sète", "Aurillac", - "Gueret", + "Guéret", "Le Creusot", "Nevers", "Auxerre", @@ -731,7 +731,7 @@ "Chaumont", "Langres", "Bourg", - "Lyons", + "Lyon", "Vienne", "Grenoble", "Toulon", @@ -763,7 +763,7 @@ "Beaujolais", "Narbonne", "Albi", - "St. Valery", + "Paris", "Biarritz", "Béziers", "Nîmes", diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/table/sprites.h --- a/src/table/sprites.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/table/sprites.h Wed Feb 28 00:33:40 2007 +0000 @@ -48,7 +48,7 @@ SPR_ASCII_SPACE_BIG = 450, /* Extra graphic spritenumbers */ - OPENTTD_SPRITES_COUNT = 116, // number of gfx-sprites in openttd.grf + OPENTTD_SPRITES_COUNT = 117, // number of gfx-sprites in openttd.grf SPR_SIGNALS_BASE = 4896, SPR_CANALS_BASE = SPR_SIGNALS_BASE + 486, SPR_SLOPES_BASE = SPR_CANALS_BASE + 70, @@ -95,6 +95,8 @@ SPR_SHARED_ORDERS_ICON = SPR_OPENTTD_BASE + 115, + SPR_WARNING_SIGN = SPR_OPENTTD_BASE + 116, // warning sign (shown if there are any newgrf errors) + /* Network GUI sprites */ SPR_SQUARE = SPR_OPENTTD_BASE + 20, // colored square (used for newgrf compatibility) SPR_LOCK = SPR_OPENTTD_BASE + 19, // lock icon (for password protected servers) diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/terraform_gui.cpp --- a/src/terraform_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/terraform_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -40,8 +40,8 @@ if (_game_mode != GM_EDITOR) return; - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); size_x = (ex - sx) + 1; size_y = (ey - sy) + 1; @@ -68,8 +68,8 @@ if (_game_mode != GM_EDITOR) return; - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); size_x = (ex - sx) + 1; size_y = (ey - sy) + 1; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/town_cmd.cpp --- a/src/town_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/town_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -350,8 +350,6 @@ int32 cost; Town *t; - // safety checks - if (!EnsureNoVehicle(tile)) return CMD_ERROR; if (flags&DC_AUTO && !(flags&DC_AI_BUILDING)) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); house = GetHouseType(tile); @@ -730,7 +728,7 @@ // Exclude the source position from the bitmask // and return if no more road blocks available - mask = ClrBitT(mask, (block ^ 2)); + ClrBitT(mask, (block ^ 2)); if (mask == 0) return _grow_town_result; @@ -1303,8 +1301,6 @@ { int32 r; - // make sure it's possible - if (!EnsureNoVehicle(tile)) return false; if (IsSteepSlope(GetTileSlope(tile, NULL))) return false; if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/train_cmd.cpp --- a/src/train_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/train_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -33,6 +33,7 @@ #include "direction.h" #include "yapf/yapf.h" #include "date.h" +#include "cargotype.h" static bool TrainCheckIfLineEnds(Vehicle *v); static void TrainController(Vehicle *v, bool update_image); @@ -48,8 +49,7 @@ */ byte FreightWagonMult(CargoID cargo) { - // XXX NewCargos introduces a specific "is freight" flag for this test. - if (cargo == CT_PASSENGERS || cargo == CT_MAIL) return 1; + if (!GetCargo(cargo)->is_freight) return 1; return _patches.freight_trains; } @@ -60,11 +60,10 @@ */ void TrainPowerChanged(Vehicle* v) { - Vehicle* u; uint32 power = 0; uint32 max_te = 0; - for (u = v; u != NULL; u = u->next) { + for (const Vehicle *u = v; u != NULL; u = u->next) { /* Power is not added for articulated parts */ if (IsArticulatedPart(u)) continue; @@ -101,17 +100,15 @@ */ static void TrainCargoChanged(Vehicle* v) { - Vehicle *u; uint32 weight = 0; - for (u = v; u != NULL; u = u->next) { - const RailVehicleInfo *rvi = RailVehInfo(u->engine_type); - uint32 vweight = (_cargoc.weights[u->cargo_type] * u->cargo_count * FreightWagonMult(u->cargo_type)) / 16; + for (Vehicle *u = v; u != NULL; u = u->next) { + uint32 vweight = GetCargo(u->cargo_type)->weight * u->cargo_count * FreightWagonMult(u->cargo_type) / 16; // Vehicle weight is not added for articulated parts. if (!IsArticulatedPart(u)) { // vehicle weight is the sum of the weight of the vehicle and the weight of its cargo - vweight += rvi->weight; + vweight += RailVehInfo(u->engine_type)->weight; // powered wagons have extra weight added if (HASBIT(u->u.rail.flags, VRF_POWEREDWAGON)) @@ -123,7 +120,7 @@ // store vehicle weight in cache u->u.rail.cached_veh_weight = vweight; - }; + } // store consist weight in cache v->u.rail.cached_weight = weight; @@ -141,29 +138,24 @@ */ void TrainConsistChanged(Vehicle* v) { - const RailVehicleInfo *rvi_v; - Vehicle *u; uint16 max_speed = 0xFFFF; - EngineID first_engine; assert(v->type == VEH_Train); - assert(IsFrontEngine(v) || IsFreeWagon(v)); - rvi_v = RailVehInfo(v->engine_type); - first_engine = IsFrontEngine(v) ? v->engine_type : INVALID_ENGINE; + const RailVehicleInfo *rvi_v = RailVehInfo(v->engine_type); + EngineID first_engine = IsFrontEngine(v) ? v->engine_type : INVALID_ENGINE; v->u.rail.cached_total_length = 0; v->u.rail.compatible_railtypes = 0; - for (u = v; u != NULL; u = u->next) { + for (Vehicle *u = v; u != NULL; u = u->next) { const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type); - uint16 veh_len; // Update the v->first cache. This is faster than having to brute force it later. if (u->first == NULL) u->first = v; // update the 'first engine' - u->u.rail.first_engine = (v == u) ? (EngineID)INVALID_ENGINE : first_engine; + u->u.rail.first_engine = v == u ? INVALID_ENGINE : first_engine; u->u.rail.railtype = rvi_u->railtype; if (IsTrainEngine(u)) first_engine = u->engine_type; @@ -184,9 +176,6 @@ } if (!IsArticulatedPart(u)) { - // check if its a powered wagon - CLRBIT(u->u.rail.flags, VRF_POWEREDWAGON); - /* Check powered wagon / visual effect callback */ if (HASBIT(EngInfo(u->engine_type)->callbackmask, CBM_WAGON_POWER)) { uint16 callback = GetVehicleCallback(CBID_TRAIN_WAGON_POWER, 0, 0, u->engine_type, u); @@ -198,6 +187,8 @@ UsesWagonOverride(u) && (u->u.rail.cached_vis_effect < 0x40)) { /* wagon is powered */ SETBIT(u->u.rail.flags, VRF_POWEREDWAGON); // cache 'powered' status + } else { + CLRBIT(u->u.rail.flags, VRF_POWEREDWAGON); } /* Do not count powered wagons for the compatible railtypes, as wagons always @@ -220,7 +211,7 @@ } // check the vehicle length (callback) - veh_len = CALLBACK_FAILED; + uint16 veh_len = CALLBACK_FAILED; if (HASBIT(EngInfo(u->engine_type)->callbackmask, CBM_VEHICLE_LENGTH)) { veh_len = GetVehicleCallback(CBID_TRAIN_VEHICLE_LENGTH, 0, 0, u->engine_type, u); } @@ -228,8 +219,7 @@ veh_len = clamp(veh_len, 0, u->next == NULL ? 7 : 5); // the clamp on vehicles not the last in chain is stricter, as too short wagons can break the 'follow next vehicle' code u->u.rail.cached_veh_length = 8 - veh_len; v->u.rail.cached_total_length += u->u.rail.cached_veh_length; - - }; + } // store consist weight/max speed in cache v->u.rail.cached_max_speed = max_speed; @@ -291,30 +281,16 @@ //new acceleration static int GetTrainAcceleration(Vehicle *v, bool mode) { - const Vehicle *u; - int num = 0; //number of vehicles, change this into the number of axles later - int power = 0; - int mass = 0; int max_speed = 2000; - int area = 120; - int friction = 35; //[1e-3] - int drag_coeff = 20; //[1e-4] - int incl = 0; - int resistance; - int speed = v->cur_speed; //[mph] - int force = 0x3FFFFFFF; + int speed = v->cur_speed * 10 / 16; //[mph] + int curvecount[2] = {0, 0}; + + //first find the curve speed limit + int numcurve = 0; + int sum = 0; int pos = 0; int lastpos = -1; - int curvecount[2] = {0, 0}; - int sum = 0; - int numcurve = 0; - int max_te = v->u.rail.cached_max_te; // [N] - - speed *= 10; - speed /= 16; - - //first find the curve speed limit - for (u = v; u->next != NULL; u = u->next, pos++) { + for (const Vehicle *u = v; u->next != NULL; u = u->next, pos++) { Direction dir = u->direction; Direction ndir = u->next->direction; int i; @@ -369,11 +345,14 @@ } } - mass = v->u.rail.cached_weight; - power = v->u.rail.cached_power * 746; + int mass = v->u.rail.cached_weight; + int power = v->u.rail.cached_power * 746; max_speed = min(max_speed, v->u.rail.cached_max_speed); - for (u = v; u != NULL; u = u->next) { + int num = 0; //number of vehicles, change this into the number of axles later + int incl = 0; + int drag_coeff = 20; //[1e-4] + for (const Vehicle *u = v; u != NULL; u = u->next) { num++; drag_coeff += 3; @@ -388,6 +367,9 @@ v->max_speed = max_speed; + const int area = 120; + const int friction = 35; //[1e-3] + int resistance; if (v->u.rail.railtype != RAILTYPE_MAGLEV) { resistance = 13 * mass / 10; resistance += 60 * num; @@ -401,6 +383,8 @@ /* Due to the mph to m/s conversion below, at speeds below 3 mph the force is * actually double the train's power */ + const int max_te = v->u.rail.cached_max_te; // [N] + int force; if (speed > 2) { switch (v->u.rail.railtype) { case RAILTYPE_RAIL: @@ -412,11 +396,10 @@ if (mode == AM_ACCEL && force > max_te) force = max_te; break; + default: NOT_REACHED(); case RAILTYPE_MAGLEV: force = power / 25; break; - - default: NOT_REACHED(); } } else { //"kickoff" acceleration @@ -437,17 +420,13 @@ static void UpdateTrainAcceleration(Vehicle* v) { - uint power = 0; - uint weight = 0; - assert(IsFrontEngine(v)); - weight = v->u.rail.cached_weight; - power = v->u.rail.cached_power; v->max_speed = v->u.rail.cached_max_speed; + uint power = v->u.rail.cached_power; + uint weight = v->u.rail.cached_weight; assert(weight != 0); - v->acceleration = clamp(power / weight * 4, 1, 255); } @@ -508,13 +487,11 @@ uint CountArticulatedParts(EngineID engine_type) { - uint16 callback; + if (!HASBIT(EngInfo(engine_type)->callbackmask, CBM_ARTIC_ENGINE)) return 0; + uint i; - - if (!HASBIT(EngInfo(engine_type)->callbackmask, CBM_ARTIC_ENGINE)) return 0; - for (i = 1; i < 10; i++) { - callback = GetVehicleCallback(CBID_TRAIN_ARTIC_ENGINE, i, 0, engine_type, NULL); + uint16 callback = GetVehicleCallback(CBID_TRAIN_ARTIC_ENGINE, i, 0, engine_type, NULL); if (callback == CALLBACK_FAILED || callback == 0xFF) break; } @@ -523,18 +500,13 @@ static void AddArticulatedParts(Vehicle **vl) { - const RailVehicleInfo *rvi_artic; - EngineID engine_type; - Vehicle *v = vl[0]; - Vehicle *u = v; - uint16 callback; - bool flip_image; - uint i; + const Vehicle *v = vl[0]; + Vehicle *u = vl[0]; if (!HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_ARTIC_ENGINE)) return; - for (i = 1; i < 10; i++) { - callback = GetVehicleCallback(CBID_TRAIN_ARTIC_ENGINE, i, 0, v->engine_type, v); + for (uint i = 1; i < 10; i++) { + uint16 callback = GetVehicleCallback(CBID_TRAIN_ARTIC_ENGINE, i, 0, v->engine_type, v); if (callback == CALLBACK_FAILED || callback == 0xFF) return; /* Attempt to use pre-allocated vehicles until they run out. This can happen @@ -545,9 +517,9 @@ u = u->next; - engine_type = GB(callback, 0, 7); - flip_image = HASBIT(callback, 7); - rvi_artic = RailVehInfo(engine_type); + EngineID engine_type = GB(callback, 0, 7); + bool flip_image = HASBIT(callback, 7); + const RailVehicleInfo *rvi_artic = RailVehInfo(engine_type); // get common values from first engine u->direction = v->direction; @@ -585,22 +557,15 @@ static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags) { - int32 value; - const RailVehicleInfo *rvi; - uint num_vehicles; - SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); - rvi = RailVehInfo(engine); - value = (rvi->base_cost * _price.build_railwagon) >> 8; - - num_vehicles = 1 + CountArticulatedParts(engine); + const RailVehicleInfo *rvi = RailVehInfo(engine); + int32 value = (rvi->base_cost * _price.build_railwagon) >> 8; + + uint num_vehicles = 1 + CountArticulatedParts(engine); if (!(flags & DC_QUERY_COST)) { Vehicle *vl[11]; // Allow for wagon and upto 10 artic parts. - Vehicle* v; - int x; - int y; memset(&vl, 0, sizeof(vl)); @@ -608,14 +573,12 @@ return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); if (flags & DC_EXEC) { - Vehicle *u, *w; - DiagDirection dir; - - v = vl[0]; + Vehicle *v = vl[0]; v->spritenum = rvi->image_index; - u = NULL; - + Vehicle *u = NULL; + + Vehicle *w; FOR_ALL_VEHICLES(w) { if (w->type == VEH_Train && w->tile == tile && IsFreeWagon(w) && w->engine_type == engine) { @@ -626,17 +589,17 @@ v->engine_type = engine; - dir = GetRailDepotDirection(tile); + DiagDirection dir = GetRailDepotDirection(tile); v->direction = DiagDirToDir(dir); v->tile = tile; - x = TileX(tile) * TILE_SIZE | _vehicle_initial_x_fract[dir]; - y = TileY(tile) * TILE_SIZE | _vehicle_initial_y_fract[dir]; + int x = TileX(tile) * TILE_SIZE | _vehicle_initial_x_fract[dir]; + int y = TileY(tile) * TILE_SIZE | _vehicle_initial_y_fract[dir]; v->x_pos = x; v->y_pos = y; - v->z_pos = GetSlopeZ(x,y); + v->z_pos = GetSlopeZ(x, y); v->owner = _current_player; v->z_height = 6; v->u.rail.track = TRACK_BIT_DEPOT; @@ -740,12 +703,6 @@ */ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - const RailVehicleInfo *rvi; - int value; - Vehicle *v; - UnitID unit_num; - uint num_vehicles; - /* Check if the engine-type is valid (for the player) */ if (!IsEngineBuildable(p1, VEH_Train, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE); @@ -758,7 +715,7 @@ SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); - rvi = RailVehInfo(p1); + const RailVehicleInfo *rvi = RailVehInfo(p1); /* Check if depot and new engine uses the same kind of tracks */ /* We need to see if the engine got power on the tile to avoid eletric engines in non-electric depots */ @@ -766,10 +723,11 @@ if (rvi->railveh_type == RAILVEH_WAGON) return CmdBuildRailWagon(p1, tile, flags); - value = EstimateTrainCost(rvi); - - num_vehicles = (rvi->railveh_type == RAILVEH_MULTIHEAD) ? 2 : 1; - num_vehicles += CountArticulatedParts(p1); + int32 value = EstimateTrainCost(rvi); + + uint num_vehicles = + (rvi->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1) + + CountArticulatedParts(p1); if (!(flags & DC_QUERY_COST)) { Vehicle *vl[12]; // Allow for upto 10 artic parts and dual-heads @@ -779,9 +737,9 @@ if (!AllocateVehicles(vl, num_vehicles)) return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); - v = vl[0]; - - unit_num = HASBIT(p2, 0) ? 0 : GetFreeUnitNumber(VEH_Train); + Vehicle *v = vl[0]; + + UnitID unit_num = HASBIT(p2, 0) ? 0 : GetFreeUnitNumber(VEH_Train); if (unit_num > _patches.max_trains) return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); @@ -796,7 +754,7 @@ v->owner = _current_player; v->x_pos = x; v->y_pos = y; - v->z_pos = GetSlopeZ(x,y); + v->z_pos = GetSlopeZ(x, y); v->z_height = 6; v->u.rail.track = TRACK_BIT_DEPOT; v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL; @@ -871,13 +829,12 @@ * number of cars (including loco) then. If not it returns -1 */ int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped) { - int count; TileIndex tile = v->tile; /* check if stopped in a depot */ if (!IsTileDepotType(tile, TRANSPORT_RAIL) || v->cur_speed != 0) return -1; - count = 0; + int count = 0; for (; v != NULL; v = v->next) { /* This count is used by the depot code to determine the number of engines * in the consist. Exclude articulated parts so that autoreplacing to @@ -903,7 +860,7 @@ /* Used to check if the train is inside the depot, but not checking the VS_STOPPED flag */ inline bool CheckTrainIsInsideDepot(const Vehicle *v) { - return (CheckTrainInDepot(v, false) > 0); + return CheckTrainInDepot(v, false) > 0; } /** @@ -914,8 +871,6 @@ */ static Vehicle *UnlinkWagon(Vehicle *v, Vehicle *first) { - Vehicle *u; - // unlinking the first vehicle of the chain? if (v == first) { v = GetNextVehicle(v); @@ -926,6 +881,7 @@ return v; } + Vehicle *u; for (u = first; GetNextVehicle(u) != v; u = GetNextVehicle(u)) {} GetLastEnginePart(u)->next = GetNextVehicle(v); return first; @@ -973,8 +929,6 @@ */ static void NormaliseTrainConsist(Vehicle *v) { - Vehicle *u; - if (IsFreeWagon(v)) return; assert(IsFrontEngine(v)); @@ -983,7 +937,8 @@ if (!IsMultiheaded(v) || !IsTrainEngine(v)) continue; /* make sure that there are no free cars before next engine */ - for (u = v; u->next != NULL && !IsTrainEngine(u->next); u = u->next); + Vehicle *u; + for (u = v; u->next != NULL && !IsTrainEngine(u->next); u = u->next) {} if (u == v->u.rail.other_multiheaded_part) continue; AddWagonToConsist(v->u.rail.other_multiheaded_part, u); @@ -1001,19 +956,21 @@ { VehicleID s = GB(p1, 0, 16); VehicleID d = GB(p1, 16, 16); - Vehicle *src, *dst, *src_head, *dst_head; if (!IsValidVehicleID(s)) return CMD_ERROR; - src = GetVehicle(s); - - if (src->type != VEH_Train) return CMD_ERROR; + Vehicle *src = GetVehicle(s); + + if (src->type != VEH_Train || !CheckOwnership(src->owner)) return CMD_ERROR; // if nothing is selected as destination, try and find a matching vehicle to drag to. + Vehicle *dst; if (d == INVALID_VEHICLE) { dst = IsTrainEngine(src) ? NULL : FindGoodVehiclePos(src); } else { + if (!IsValidVehicleID(d)) return CMD_ERROR; dst = GetVehicle(d); + if (dst->type != VEH_Train || !CheckOwnership(dst->owner)) return CMD_ERROR; } // if an articulated part is being handled, deal with its parent vehicle @@ -1025,17 +982,16 @@ // don't move the same vehicle.. if (src == dst) return 0; - /* the player must be the owner */ - if (!CheckOwnership(src->owner) || (dst != NULL && !CheckOwnership(dst->owner))) - return CMD_ERROR; - /* locate the head of the two chains */ - src_head = GetFirstVehicleInChain(src); - dst_head = NULL; + Vehicle *src_head = GetFirstVehicleInChain(src); + Vehicle *dst_head; if (dst != NULL) { dst_head = GetFirstVehicleInChain(dst); + if (dst_head->tile != src_head->tile) return CMD_ERROR; // Now deal with articulated part of destination wagon dst = GetLastEnginePart(dst); + } else { + dst_head = NULL; } if (dst != NULL && IsMultiheaded(dst) && !IsTrainEngine(dst) && IsTrainWagon(src)) { @@ -1055,9 +1011,9 @@ if (IsTrainEngine(src) && dst_head != NULL) { /* we need to make sure that we didn't place it between a pair of multiheaded engines */ - Vehicle *u, *engine = NULL; - - for (u = dst_head; u != NULL; u = u->next) { + Vehicle *engine = NULL; + + for (Vehicle *u = dst_head; u != NULL; u = u->next) { if (IsTrainEngine(u) && IsMultiheaded(u) && u->u.rail.other_multiheaded_part != NULL) { engine = u; } @@ -1077,11 +1033,10 @@ if (HASBIT(p2, 0) && src_head == dst_head) return 0; { - int src_len = 0; int max_len = _patches.mammoth_trains ? 100 : 9; // check if all vehicles in the source train are stopped inside a depot. - src_len = CheckTrainStoppedInDepot(src_head); + int src_len = CheckTrainStoppedInDepot(src_head); if (src_len < 0) return_cmd_error(STR_881A_TRAINS_CAN_ONLY_BE_ALTERED); // check the destination row if the source and destination aren't the same. @@ -1092,8 +1047,6 @@ // check if all vehicles in the dest train are stopped. dst_len = CheckTrainStoppedInDepot(dst_head); if (dst_len < 0) return_cmd_error(STR_881A_TRAINS_CAN_ONLY_BE_ALTERED); - - assert(dst_head->tile == src_head->tile); } // We are moving between rows, so only count the wagons from the source @@ -1144,12 +1097,8 @@ /* do it? */ if (flags & DC_EXEC) { /* clear the ->first cache */ - { - Vehicle *u; - - for (u = src_head; u != NULL; u = u->next) u->first = NULL; - for (u = dst_head; u != NULL; u = u->next) u->first = NULL; - } + for (Vehicle *u = src_head; u != NULL; u = u->next) u->first = NULL; + for (Vehicle *u = dst_head; u != NULL; u = u->next) u->first = NULL; if (HASBIT(p2, 0)) { // unlink ALL wagons @@ -1257,7 +1206,7 @@ } /* Update the depot window */ InvalidateWindow(WC_VEHICLE_DEPOT, src_head->tile); - }; + } if (dst_head != NULL) { NormaliseTrainConsist(dst_head); @@ -1286,18 +1235,15 @@ */ int32 CmdStartStopTrain(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Vehicle *v; - uint16 callback; - if (!IsValidVehicleID(p1)) return CMD_ERROR; - v = GetVehicle(p1); + Vehicle *v = GetVehicle(p1); if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR; /* Check if this train can be started/stopped. The callback will fail or * return 0xFF if it can. */ - callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v); + uint16 callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v); if (callback != CALLBACK_FAILED && callback != 0xFF) { StringID error = GetGRFStringID(GetEngineGRFID(v->engine_type), 0xD000 + callback); return_cmd_error(error); @@ -1330,20 +1276,16 @@ */ int32 CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Vehicle *v, *tmp, *first; - Vehicle *new_f = NULL; - int32 cost = 0; - if (!IsValidVehicleID(p1) || p2 > 2) return CMD_ERROR; - v = GetVehicle(p1); + Vehicle *v = GetVehicle(p1); if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR; SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); while (IsArticulatedPart(v)) v = GetPrevVehicleInChain(v); - first = GetFirstVehicleInChain(v); + Vehicle *first = GetFirstVehicleInChain(v); // make sure the vehicle is stopped in the depot if (CheckTrainStoppedInDepot(first) < 0) { @@ -1360,6 +1302,7 @@ RebuildVehicleLists(); } + int32 cost = 0; switch (p2) { case 0: case 2: { /* Delete given wagon */ bool switch_engine = false; // update second wagon to engine? @@ -1382,10 +1325,10 @@ /* 2. We are selling the first engine, some special action might be required * here, so take attention */ if ((flags & DC_EXEC) && v == first) { - new_f = GetNextVehicle(first); + Vehicle *new_f = GetNextVehicle(first); /* 2.1 If the first wagon is sold, update the first-> pointers to NULL */ - for (tmp = first; tmp != NULL; tmp = tmp->next) tmp->first = NULL; + for (Vehicle *tmp = first; tmp != NULL; tmp = tmp->next) tmp->first = NULL; /* 2.2 If there are wagons present after the deleted front engine, check * if the second wagon (which will be first) is an engine. If it is one, @@ -1443,6 +1386,7 @@ * Totally braindead cause building a new engine adds all loco-less * engines to its train anyways */ if (p2 == 2 && HASBIT(ori_subtype, Train_Front)) { + Vehicle *tmp; for (v = first; v != NULL; v = tmp) { tmp = GetNextVehicle(v); DoCommand(v->tile, v->index | INVALID_VEHICLE << 16, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); @@ -1454,6 +1398,7 @@ /* Start deleting every vehicle after the selected one * If we encounter a matching rear-engine to a front-engine * earlier in the chain (before deletion), leave it alone */ + Vehicle *tmp; for (; v != NULL; v = tmp) { tmp = GetNextVehicle(v); @@ -1541,10 +1486,8 @@ static void SwapTrainFlags(byte *swap_flag1, byte *swap_flag2) { - byte flag1, flag2; - - flag1 = *swap_flag1; - flag2 = *swap_flag2; + byte flag1 = *swap_flag1; + byte flag2 = *swap_flag2; /* Clear the flags */ CLRBIT(*swap_flag1, VRF_GOINGUP); @@ -1638,35 +1581,25 @@ */ static void AdvanceWagons(Vehicle *v, bool before) { - Vehicle* base; - Vehicle* first; - int length; - - base = v; - first = base->next; - length = CountVehiclesInChain(v); + Vehicle *base = v; + Vehicle *first = base->next; + uint length = CountVehiclesInChain(v); while (length > 2) { - Vehicle* last; - int differential; - int i; - // find pairwise matching wagon // start<>end, start+1<>end-1, ... - last = first; - for (i = length - 3; i > 0; i--) last = last->next; - - differential = last->u.rail.cached_veh_length - base->u.rail.cached_veh_length; + Vehicle *last = first; + for (uint i = length - 3; i > 0; i--) last = last->next; + + int differential = last->u.rail.cached_veh_length - base->u.rail.cached_veh_length; if (before) differential *= -1; if (differential > 0) { - Vehicle* tempnext; - // disconnect last car to make sure only this subset moves - tempnext = last->next; + Vehicle *tempnext = last->next; last->next = NULL; - for (i = 0; i < differential; i++) TrainController(first, false); + for (int i = 0; i < differential; i++) TrainController(first, false); last->next = tempnext; } @@ -1680,9 +1613,6 @@ static void ReverseTrainDirection(Vehicle *v) { - int l = 0, r = -1; - Vehicle *u; - if (IsTileDepotType(v->tile, TRANSPORT_RAIL)) { InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); } @@ -1704,12 +1634,14 @@ } // count number of vehicles - u = v; + int r = -1; + const Vehicle *u = v; do r++; while ( (u = u->next) != NULL ); AdvanceWagons(v, true); /* swap start<>end, start+1<>end-1, ... */ + int l = 0; do { ReverseTrainSwapVeh(v, l++, r--); } while (l <= r); @@ -1730,23 +1662,20 @@ */ int32 CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Vehicle *v; - if (!IsValidVehicleID(p1)) return CMD_ERROR; - v = GetVehicle(p1); + Vehicle *v = GetVehicle(p1); if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR; if (p2) { // turn a single unit around - Vehicle *front; if (IsMultiheaded(v) || HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_ARTIC_ENGINE)) { return_cmd_error(STR_ONLY_TURN_SINGLE_UNIT); } - front = GetFirstVehicleInChain(v); + Vehicle *front = GetFirstVehicleInChain(v); // make sure the vehicle is stopped in the depot if (CheckTrainStoppedInDepot(front) < 0) { return_cmd_error(STR_881A_TRAINS_CAN_ONLY_BE_ALTERED); @@ -1781,11 +1710,9 @@ */ int32 CmdForceTrainProceed(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Vehicle *v; - if (!IsValidVehicleID(p1)) return CMD_ERROR; - v = GetVehicle(p1); + Vehicle *v = GetVehicle(p1); if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR; @@ -1805,13 +1732,10 @@ { CargoID new_cid = GB(p2, 0, 8); byte new_subtype = GB(p2, 8, 8); - Vehicle *v; - int32 cost; - uint num; if (!IsValidVehicleID(p1)) return CMD_ERROR; - v = GetVehicle(p1); + Vehicle *v = GetVehicle(p1); if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR; if (CheckTrainStoppedInDepot(v) < 0) return_cmd_error(STR_TRAIN_MUST_BE_STOPPED); @@ -1821,8 +1745,8 @@ SET_EXPENSES_TYPE(EXPENSES_TRAIN_RUN); - cost = 0; - num = 0; + int32 cost = 0; + uint num = 0; do { /* XXX: We also refit all the attached wagons en-masse if they @@ -1831,7 +1755,6 @@ if (!CanRefitTo(v->engine_type, new_cid)) continue; if (v->cargo_cap != 0) { - const RailVehicleInfo *rvi = RailVehInfo(v->engine_type); uint16 amount = CALLBACK_FAILED; if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) { @@ -1848,6 +1771,7 @@ } if (amount == CALLBACK_FAILED) { // callback failed or not used, use default + const RailVehicleInfo *rvi = RailVehInfo(v->engine_type); CargoID old_cid = rvi->cargo_type; /* normally, the capacity depends on the cargo type, a rail vehicle can * carry twice as much mail/goods as normal cargo, and four times as @@ -1866,7 +1790,7 @@ case CT_GOODS: amount /= 2; break; default: amount /= 4; break; } - }; + } if (amount != 0) { if (new_cid != v->cargo_type) { @@ -1924,16 +1848,15 @@ // crashed! static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance) { + assert(!(v->vehstatus & VS_CRASHED)); + TrainFindDepotData tfdd; - TileIndex tile = v->tile; - - assert(!(v->vehstatus & VS_CRASHED)); - tfdd.owner = v->owner; tfdd.best_length = (uint)-1; tfdd.reverse = false; - if (IsTileDepotType(tile, TRANSPORT_RAIL)){ + TileIndex tile = v->tile; + if (IsTileDepotType(tile, TRANSPORT_RAIL)) { tfdd.tile = tile; tfdd.best_length = 0; return tfdd; @@ -1943,13 +1866,12 @@ bool found = YapfFindNearestRailDepotTwoWay(v, max_distance, NPF_INFINITE_PENALTY, &tfdd.tile, &tfdd.reverse); tfdd.best_length = found ? max_distance / 2 : -1; // some fake distance or NOT_FOUND } else if (_patches.new_pathfinding_all) { - NPFFoundTargetData ftd; Vehicle* last = GetLastVehicleInChain(v); Trackdir trackdir = GetVehicleTrackdir(v); Trackdir trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last)); - assert (trackdir != INVALID_TRACKDIR); - ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, last->tile, trackdir_rev, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY); + assert(trackdir != INVALID_TRACKDIR); + NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, last->tile, trackdir_rev, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY); if (ftd.best_bird_dist == 0) { /* Found target */ tfdd.tile = ftd.node.tile; @@ -1962,9 +1884,7 @@ } } else { // search in the forward direction first. - DiagDirection i; - - i = DirToDiagDir(v->direction); + DiagDirection i = DirToDiagDir(v->direction); if (!(v->direction & 1) && v->u.rail.track != _state_dir_table[i]) { i = ChangeDiagDir(i, DIAGDIRDIFF_90LEFT); } @@ -1992,9 +1912,6 @@ */ int32 CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { - Vehicle *v; - TrainFindDepotData tfdd; - if (p2 & DEPOT_MASS_SEND) { /* Mass goto depot requested */ if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR; @@ -2003,7 +1920,7 @@ if (!IsValidVehicleID(p1)) return CMD_ERROR; - v = GetVehicle(p1); + Vehicle *v = GetVehicle(p1); if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR; @@ -2039,7 +1956,7 @@ * the check is down here to make it possible to alter stop/service for trains entering the depot */ if (IsTileDepotType(v->tile, TRANSPORT_RAIL) && v->cur_speed == 0) return CMD_ERROR; - tfdd = FindClosestTrainDepot(v, 0); + TrainFindDepotData tfdd = FindClosestTrainDepot(v, 0); if (tfdd.best_length == (uint)-1) return_cmd_error(STR_883A_UNABLE_TO_FIND_ROUTE_TO); if (flags & DC_EXEC) { @@ -2070,20 +1987,18 @@ static void HandleLocomotiveSmokeCloud(const Vehicle* v) { - const Vehicle* u; bool sound = false; if (v->vehstatus & VS_TRAIN_SLOWING || v->load_unload_time_rem != 0 || v->cur_speed < 2) return; - u = v; + const Vehicle* u = v; do { const RailVehicleInfo *rvi = RailVehInfo(v->engine_type); int effect_offset = GB(v->u.rail.cached_vis_effect, 0, 4) - 8; byte effect_type = GB(v->u.rail.cached_vis_effect, 4, 2); bool disable_effect = HASBIT(v->u.rail.cached_vis_effect, 6); - int x, y; // no smoke? if ((rvi->railveh_type == RAILVEH_WAGON && effect_type == 0) || @@ -2097,7 +2012,7 @@ if (IsTileDepotType(v->tile, TRANSPORT_RAIL) || IsTunnelTile(v->tile)) continue; // No sparks for electric vehicles on nonelectrified tracks - if (!HasPowerOnRail(v->u.rail.railtype, GetTileRailType(v->tile, TrackdirToTrack(GetVehicleTrackdir(v))))) continue; + if (!HasPowerOnRail(v->u.rail.railtype, GetTileRailType(v->tile))) continue; if (effect_type == 0) { // Use default effect type for engine class. @@ -2106,8 +2021,8 @@ effect_type--; } - x = _vehicle_smoke_pos[v->direction] * effect_offset; - y = _vehicle_smoke_pos[(v->direction + 2) % 8] * effect_offset; + int x = _vehicle_smoke_pos[v->direction] * effect_offset; + int y = _vehicle_smoke_pos[(v->direction + 2) % 8] * effect_offset; if (HASBIT(v->u.rail.flags, VRF_REVERSE_DIRECTION)) { x = -x; @@ -2152,10 +2067,9 @@ SND_0A_TRAIN_HORN }; + if (PlayVehicleSound(v, VSE_START)) return; + EngineID engtype = v->engine_type; - - if (PlayVehicleSound(v, VSE_START)) return; - switch (RailVehInfo(engtype)->railtype) { case RAILTYPE_RAIL: case RAILTYPE_ELECTRIC: @@ -2170,10 +2084,8 @@ static bool CheckTrainStayInDepot(Vehicle *v) { - Vehicle *u; - // bail out if not all wagons are in the same depot or not in a depot at all - for (u = v; u != NULL; u = u->next) { + for (const Vehicle *u = v; u != NULL; u = u->next) { if (u->u.rail.track != TRACK_BIT_DEPOT || u->tile != v->tile) return false; } @@ -2245,10 +2157,8 @@ ttfd->best_track = track; return true; } else { - uint dist; - // didn't find station, keep track of the best path so far. - dist = DistanceManhattan(tile, ttfd->dest_coords); + uint dist = DistanceManhattan(tile, ttfd->dest_coords); if (dist < ttfd->best_bird_dist) { ttfd->best_bird_dist = dist; ttfd->best_track = track; @@ -2297,7 +2207,6 @@ /* choose a track */ static Track ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) { - TrainTrackFollowerData fd; Track best_track; // pathfinders are able to tell that route was only 'guessed' bool path_not_found = false; @@ -2320,18 +2229,14 @@ } } else if (_patches.new_pathfinding_all) { /* Use a new pathfinding for everything */ void* perf = NpfBeginInterval(); - int time = 0; NPFFindStationOrTileData fstd; - NPFFoundTargetData ftd; - Trackdir trackdir; - NPFFillWithOrderData(&fstd, v); /* The enterdir for the new tile, is the exitdir for the old tile */ - trackdir = GetVehicleTrackdir(v); + Trackdir trackdir = GetVehicleTrackdir(v); assert(trackdir != 0xff); - ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes); + NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes); if (ftd.best_trackdir == 0xff) { /* We are already at our target. Just do something */ @@ -2348,12 +2253,12 @@ best_track = TrackdirToTrack(ftd.best_trackdir); } - time = NpfEndInterval(perf); + int time = NpfEndInterval(perf); DEBUG(yapf, 4, "[NPFT] %d us - %d rounds - %d open - %d closed -- ", time, 0, _aystar_stats_open_size, _aystar_stats_closed_size); } else { void* perf = NpfBeginInterval(); - int time = 0; - + + TrainTrackFollowerData fd; FillWithStationData(&fd, v); /* New train pathfinding */ @@ -2374,7 +2279,7 @@ best_track = TrackdirToTrack(fd.best_track); } - time = NpfEndInterval(perf); + int time = NpfEndInterval(perf); DEBUG(yapf, 4, "[NTPT] %d us - %d rounds - %d open - %d closed -- ", time, 0, 0, 0); } // handle "path not found" state @@ -2412,26 +2317,19 @@ static bool CheckReverseTrain(Vehicle *v) { - TrainTrackFollowerData fd; - int i, r; - int best_track; - uint best_bird_dist = 0; - uint best_track_dist = 0; - uint reverse, reverse_best; - if (_opt.diff.line_reverse_mode != 0 || v->u.rail.track == TRACK_BIT_DEPOT || v->u.rail.track == TRACK_BIT_WORMHOLE || !(v->direction & 1)) return false; + TrainTrackFollowerData fd; FillWithStationData(&fd, v); - best_track = -1; - reverse_best = reverse = 0; + uint reverse_best = 0; assert(v->u.rail.track); - i = _search_directions[FIND_FIRST_BIT(v->u.rail.track)][DirToDiagDir(v->direction)]; + int i = _search_directions[FIND_FIRST_BIT(v->u.rail.track)][DirToDiagDir(v->direction)]; if (_patches.yapf.rail_use_yapf) { reverse_best = YapfCheckReverseTrain(v); @@ -2460,6 +2358,11 @@ } } } else { + int best_track = -1; + uint reverse = 0; + uint best_bird_dist = 0; + uint best_track_dist = 0; + for (;;) { fd.best_bird_dist = (uint)-1; fd.best_track_dist = (uint)-1; @@ -2489,7 +2392,7 @@ /* if we reach this position, there's two paths of equal value so far. * pick one randomly. */ - r = GB(Random(), 0, 8); + int r = GB(Random(), 0, 8); if (_pick_track_table[i] == (v->direction & 3)) r += 80; if (_pick_track_table[best_track] == (v->direction & 3)) r -= 80; if (r <= 127) goto bad; @@ -2510,9 +2413,6 @@ static bool ProcessTrainOrder(Vehicle *v) { - const Order *order; - bool at_waypoint = false; - switch (v->current_order.type) { case OT_GOTO_DEPOT: if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return false; @@ -2530,6 +2430,7 @@ } // check if we've reached the waypoint? + bool at_waypoint = false; if (v->current_order.type == OT_GOTO_WAYPOINT && v->tile == v->dest_tile) { v->cur_order_index++; at_waypoint = true; @@ -2546,7 +2447,7 @@ // Get the current order if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0; - order = GetVehicleOrder(v, v->cur_order_index); + const Order *order = GetVehicleOrder(v, v->cur_order_index); // If no order, do nothing. if (order == NULL) { @@ -2651,7 +2552,6 @@ static int UpdateTrainSpeed(Vehicle *v) { - uint spd; uint accel; if (v->vehstatus & VS_STOPPED || HASBIT(v->u.rail.flags, VRF_REVERSING)) { @@ -2668,7 +2568,7 @@ } } - spd = v->subspeed + accel * 2; + uint spd = v->subspeed + accel * 2; v->subspeed = (byte)spd; { int tempmax = v->max_speed; @@ -2686,17 +2586,16 @@ static void TrainEnterStation(Vehicle *v, StationID station) { - Station *st; - uint32 flags; - v->last_station_visited = station; /* check if a train ever visited this station before */ - st = GetStation(station); + Station *st = GetStation(station); if (!(st->had_vehicle_of_type & HVOT_TRAIN)) { st->had_vehicle_of_type |= HVOT_TRAIN; SetDParam(0, st->index); - flags = (v->owner == _local_player) ? NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_PLAYER, 0) : NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_OTHER, 0); + uint32 flags = v->owner == _local_player ? + NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ARRIVAL_PLAYER, 0) : + NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ARRIVAL_OTHER, 0); AddNewsItem( STR_8801_CITIZENS_CELEBRATE_FIRST, flags, @@ -2732,12 +2631,10 @@ static byte AfterSetTrainPos(Vehicle *v, bool new_tile) { - byte new_z, old_z; - // need this hint so it returns the right z coordinate on bridges. - new_z = GetSlopeZ(v->x_pos, v->y_pos); - - old_z = v->z_pos; + byte new_z = GetSlopeZ(v->x_pos, v->y_pos); + + byte old_z = v->z_pos; v->z_pos = new_z; if (new_tile) { @@ -2832,25 +2729,21 @@ /* Modify the speed of the vehicle due to a turn */ static void AffectSpeedByDirChange(Vehicle* v, Direction new_dir) { - DirDiff diff; - const RailtypeSlowdownParams *rsp; - if (_patches.realistic_acceleration) return; - diff = DirDifference(v->direction, new_dir); + DirDiff diff = DirDifference(v->direction, new_dir); if (diff == DIRDIFF_SAME) return; - rsp = &_railtype_slowdown[v->u.rail.railtype]; + const RailtypeSlowdownParams *rsp = &_railtype_slowdown[v->u.rail.railtype]; v->cur_speed -= (diff == DIRDIFF_45RIGHT || diff == DIRDIFF_45LEFT ? rsp->small_turn : rsp->large_turn) * v->cur_speed >> 8; } /* Modify the speed of the vehicle due to a change in altitude */ static void AffectSpeedByZChange(Vehicle *v, byte old_z) { - const RailtypeSlowdownParams *rsp; if (old_z == v->z_pos || _patches.realistic_acceleration) return; - rsp = &_railtype_slowdown[v->u.rail.railtype]; + const RailtypeSlowdownParams *rsp = &_railtype_slowdown[v->u.rail.railtype]; if (old_z < v->z_pos) { v->cur_speed -= (v->cur_speed * rsp->z_up >> 8); @@ -2899,13 +2792,11 @@ static void SetVehicleCrashed(Vehicle *v) { - Vehicle *u; - if (v->u.rail.crash_anim_pos != 0) return; v->u.rail.crash_anim_pos++; - u = v; + Vehicle *u = v; BEGIN_ENUM_WAGONS(v) v->vehstatus |= VS_CRASHED; END_ENUM_WAGONS(v) @@ -2930,24 +2821,20 @@ */ static void CheckTrainCollision(Vehicle *v) { - TrainCollideChecker tcc; - Vehicle *coll; - Vehicle *realcoll; - uint num; - /* can't collide in depot */ if (v->u.rail.track == TRACK_BIT_DEPOT) return; assert(v->u.rail.track == TRACK_BIT_WORMHOLE || TileVirtXY(v->x_pos, v->y_pos) == v->tile); + TrainCollideChecker tcc; tcc.v = v; tcc.v_skip = v->next; /* find colliding vehicle */ - realcoll = (Vehicle*)VehicleFromPos(TileVirtXY(v->x_pos, v->y_pos), &tcc, FindTrainCollideEnum); + Vehicle *realcoll = (Vehicle*)VehicleFromPos(TileVirtXY(v->x_pos, v->y_pos), &tcc, FindTrainCollideEnum); if (realcoll == NULL) return; - coll = GetFirstVehicleInChain(realcoll); + Vehicle *coll = GetFirstVehicleInChain(realcoll); /* it can't collide with its own wagons */ if (v == coll || @@ -2955,7 +2842,7 @@ return; //two drivers + passangers killed in train v - num = 2 + CountPassengersInTrain(v); + uint num = 2 + CountPassengersInTrain(v); if (!(coll->vehstatus & VS_CRASHED)) //two drivers + passangers killed in train coll (if it was not crashed already) num += 2 + CountPassengersInTrain(coll); @@ -2994,23 +2881,15 @@ static void TrainController(Vehicle *v, bool update_image) { Vehicle *prev; - GetNewVehiclePosResult gp; - uint32 r, tracks, ts; - Trackdir i; - DiagDirection enterdir; - Direction dir; - Direction newdir; - Direction chosen_dir; - TrackBits chosen_track; - byte old_z; /* For every vehicle after and including the given vehicle */ for (prev = GetPrevVehicleInChain(v); v != NULL; prev = v, v = v->next) { BeginVehicleMove(v); + GetNewVehiclePosResult gp = GetNewVehiclePos(v); if (v->u.rail.track != TRACK_BIT_WORMHOLE) { /* Not inside tunnel */ - if (GetNewVehiclePos(v, &gp)) { + if (gp.old_tile == gp.new_tile) { /* Staying in the old tile */ if (v->u.rail.track == TRACK_BIT_DEPOT) { /* Inside depot */ @@ -3021,7 +2900,7 @@ if (IsFrontEngine(v) && !TrainCheckIfLineEnds(v)) return; - r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y); + uint32 r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y); if (HASBIT(r, VETS_CANNOT_ENTER)) { goto invalid_rail; } @@ -3039,21 +2918,20 @@ } else { /* A new tile is about to be entered. */ - TrackBits bits; /* Determine what direction we're entering the new tile from */ - dir = GetNewVehicleDirectionByTile(gp.new_tile, gp.old_tile); - enterdir = DirToDiagDir(dir); + Direction dir = GetNewVehicleDirectionByTile(gp.new_tile, gp.old_tile); + DiagDirection enterdir = DirToDiagDir(dir); assert(IsValidDiagDirection(enterdir)); /* Get the status of the tracks in the new tile and mask * away the bits that aren't reachable. */ - ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL) & _reachable_tracks[enterdir]; + uint32 ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL) & _reachable_tracks[enterdir]; /* Combine the from & to directions. * Now, the lower byte contains the track status, and the byte at bit 16 contains * the signal status. */ - tracks = ts | (ts >> 8); - bits = (TrackBits)(tracks & TRACK_BIT_MASK); + uint32 tracks = ts | (ts >> 8); + TrackBits bits = (TrackBits)(tracks & TRACK_BIT_MASK); if ((_patches.new_pathfinding_all || _patches.yapf.rail_use_yapf) && _patches.forbid_90_deg && prev == NULL) { /* We allow wagons to make 90 deg turns, because forbid_90_deg * can be switched on halfway a turn */ @@ -3066,14 +2944,41 @@ * with the current train, if not, bail out. */ if (!CheckCompatibleRail(v, gp.new_tile)) goto invalid_rail; + TrackBits chosen_track; if (prev == NULL) { /* Currently the locomotive is active. Determine which one of the * available tracks to choose */ - chosen_track = 1 << ChooseTrainTrack(v, gp.new_tile, enterdir, bits); + chosen_track = TrackToTrackBits(ChooseTrainTrack(v, gp.new_tile, enterdir, bits)); assert(chosen_track & tracks); /* Check if it's a red signal and that force proceed is not clicked. */ - if ((tracks >> 16) & chosen_track && v->u.rail.force_proceed == 0) goto red_light; + if ((tracks >> 16) & chosen_track && v->u.rail.force_proceed == 0) { + // In front of a red signal + /* find the first set bit in ts. need to do it in 2 steps, since + * FIND_FIRST_BIT only handles 6 bits at a time. */ + Trackdir i = FindFirstTrackdir((TrackdirBits)(uint16)ts); + + if (!HasSignalOnTrackdir(gp.new_tile, ReverseTrackdir(i))) { + v->cur_speed = 0; + v->subspeed = 0; + v->progress = 255 - 100; + if (++v->load_unload_time_rem < _patches.wait_oneway_signal * 20) return; + } else if (HasSignalOnTrackdir(gp.new_tile, i)) { + v->cur_speed = 0; + v->subspeed = 0; + v->progress = 255-10; + if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73) { + TileIndex o_tile = gp.new_tile + TileOffsByDiagDir(enterdir); + VehicleAtSignalData vasd; + vasd.tile = o_tile; + vasd.direction = ReverseDir(dir); + + /* check if a train is waiting on the other side */ + if (VehicleFromPos(o_tile, &vasd, CheckVehicleAtSignal) == NULL) return; + } + } + goto reverse_train_direction; + } } else { static const TrackBits _matching_tracks[8] = { TRACK_BIT_LEFT | TRACK_BIT_RIGHT, TRACK_BIT_X, @@ -3093,15 +2998,13 @@ chosen_track == TRACK_BIT_LEFT || chosen_track == TRACK_BIT_RIGHT); /* Update XY to reflect the entrance to the new tile, and select the direction to use */ - { - const byte *b = _initial_tile_subcoord[FIND_FIRST_BIT(chosen_track)][enterdir]; - gp.x = (gp.x & ~0xF) | b[0]; - gp.y = (gp.y & ~0xF) | b[1]; - chosen_dir = (Direction)b[2]; - } + const byte *b = _initial_tile_subcoord[FIND_FIRST_BIT(chosen_track)][enterdir]; + gp.x = (gp.x & ~0xF) | b[0]; + gp.y = (gp.y & ~0xF) | b[1]; + Direction chosen_dir = (Direction)b[2]; /* Call the landscape function and tell it that the vehicle entered the tile */ - r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y); + uint32 r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y); if (HASBIT(r, VETS_CANNOT_ENTER)) { goto invalid_rail; } @@ -3116,7 +3019,7 @@ if (!HASBIT(r, VETS_ENTERED_WORMHOLE)) { v->tile = gp.new_tile; - if (GetTileRailType(gp.new_tile, FindFirstTrack(chosen_track)) != GetTileRailType(gp.old_tile, FindFirstTrack(v->u.rail.track))) { + if (GetTileRailType(gp.new_tile) != GetTileRailType(gp.old_tile)) { TrainPowerChanged(GetFirstVehicleInChain(v)); } @@ -3136,9 +3039,10 @@ } } else { /* In tunnel or on a bridge */ - GetNewVehiclePos(v, &gp); - - SetSpeedLimitOnBridge(v); + if (!(v->vehstatus & VS_HIDDEN)) { + v->cur_speed = + min(v->cur_speed, GetBridge(GetBridgeType(v->tile))->speed); + } if (!(IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) || !HASBIT(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) { v->x_pos = gp.x; @@ -3150,7 +3054,7 @@ } /* update image of train, as well as delta XY */ - newdir = GetNewVehicleDirection(v, gp.x, gp.y); + Direction newdir = GetNewVehicleDirection(v, gp.x, gp.y); UpdateTrainDeltaXY(v, newdir); if (update_image) v->cur_image = GetTrainImage(v, newdir); @@ -3158,7 +3062,7 @@ v->y_pos = gp.y; /* update the Z position of the vehicle */ - old_z = AfterSetTrainPos(v, (gp.new_tile != gp.old_tile)); + byte old_z = AfterSetTrainPos(v, (gp.new_tile != gp.old_tile)); if (prev == NULL) { /* This is the first vehicle in the train */ @@ -3170,34 +3074,6 @@ invalid_rail: /* We've reached end of line?? */ if (prev != NULL) error("!Disconnecting train"); - goto reverse_train_direction; - -red_light: { - /* We're in front of a red signal ?? */ - /* find the first set bit in ts. need to do it in 2 steps, since - * FIND_FIRST_BIT only handles 6 bits at a time. */ - i = FindFirstTrackdir((TrackdirBits)(uint16)ts); - - if (!HasSignalOnTrackdir(gp.new_tile, ReverseTrackdir(i))) { - v->cur_speed = 0; - v->subspeed = 0; - v->progress = 255 - 100; - if (++v->load_unload_time_rem < _patches.wait_oneway_signal * 20) return; - } else if (HasSignalOnTrackdir(gp.new_tile, i)){ - v->cur_speed = 0; - v->subspeed = 0; - v->progress = 255-10; - if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73) { - TileIndex o_tile = gp.new_tile + TileOffsByDiagDir(enterdir); - VehicleAtSignalData vasd; - vasd.tile = o_tile; - vasd.direction = ReverseDir(dir); - - /* check if a train is waiting on the other side */ - if (VehicleFromPos(o_tile, &vasd, CheckVehicleAtSignal) == NULL) return; - } - } - } reverse_train_direction: v->load_unload_time_rem = 0; @@ -3217,11 +3093,10 @@ */ static void DeleteLastWagon(Vehicle *v) { - Vehicle *u = v; - /* Go to the last wagon and delete the link pointing there * *u is then the one-before-last wagon, and *v the last * one which will physicially be removed */ + Vehicle *u = v; for (; v->next != NULL; v = v->next) u = v; u->next = NULL; @@ -3289,17 +3164,16 @@ static void HandleCrashedTrain(Vehicle *v) { int state = ++v->u.rail.crash_anim_pos; - uint32 r; - Vehicle *u; if (state == 4 && !(v->vehstatus & VS_HIDDEN)) { CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE); } + uint32 r; if (state <= 200 && CHANCE16R(1, 7, r)) { int index = (r * 10 >> 16); - u = v; + Vehicle *u = v; do { if (--index < 0) { r = Random(); @@ -3358,18 +3232,11 @@ static bool TrainCheckIfLineEnds(Vehicle *v) { - TileIndex tile; - uint x,y; - uint16 break_speed; - DiagDirection dir; - int t; - uint32 ts; - - t = v->breakdown_ctr; + int t = v->breakdown_ctr; if (t > 1) { v->vehstatus |= VS_TRAIN_SLOWING; - break_speed = _breakdown_speeds[GB(~t, 4, 4)]; + uint16 break_speed = _breakdown_speeds[GB(~t, 4, 4)]; if (break_speed < v->cur_speed) v->cur_speed = break_speed; } else { v->vehstatus &= ~VS_TRAIN_SLOWING; @@ -3378,12 +3245,10 @@ if (v->u.rail.track == TRACK_BIT_WORMHOLE) return true; // exit if inside a tunnel if (v->u.rail.track == TRACK_BIT_DEPOT) return true; // exit if inside a depot - tile = v->tile; + TileIndex tile = v->tile; if (IsTileType(tile, MP_TUNNELBRIDGE)) { - DiagDirection dir; - - dir = IsTunnel(tile) ? GetTunnelDirection(tile) : GetBridgeRampDirection(tile); + DiagDirection dir = IsTunnel(tile) ? GetTunnelDirection(tile) : GetBridgeRampDirection(tile); if (DiagDirToDir(dir) == v->direction) return true; } @@ -3394,18 +3259,18 @@ return true;*/ /* Determine the non-diagonal direction in which we will exit this tile */ - dir = DirToDiagDir(v->direction); + DiagDirection dir = DirToDiagDir(v->direction); if (!(v->direction & 1) && v->u.rail.track != _state_dir_table[dir]) { dir = ChangeDiagDir(dir, DIAGDIRDIFF_90LEFT); } /* Calculate next tile */ tile += TileOffsByDiagDir(dir); // determine the track status on the next tile. - ts = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _reachable_tracks[dir]; + uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _reachable_tracks[dir]; /* Calc position within the current tile ?? */ - x = v->x_pos & 0xF; - y = v->y_pos & 0xF; + uint x = v->x_pos & 0xF; + uint y = v->y_pos & 0xF; switch (v->direction) { case DIR_N : x = ~x + ~y + 24; break; @@ -3447,7 +3312,7 @@ // slow down v->vehstatus |= VS_TRAIN_SLOWING; - break_speed = _breakdown_speeds[x & 0xF]; + uint16 break_speed = _breakdown_speeds[x & 0xF]; if (!(v->direction & 1)) break_speed >>= 1; if (break_speed < v->cur_speed) v->cur_speed = break_speed; @@ -3456,8 +3321,6 @@ static void TrainLocoHandler(Vehicle *v, bool mode) { - int j; - /* train has crashed? */ if (v->u.rail.crash_anim_pos != 0) { if (!mode) HandleCrashedTrain(v); @@ -3498,7 +3361,7 @@ if (!mode) HandleLocomotiveSmokeCloud(v); - j = UpdateTrainSpeed(v); + int j = UpdateTrainSpeed(v); if (j == 0) { // if the vehicle has speed 0, update the last_speed field. if (v->cur_speed != 0) return; @@ -3541,9 +3404,6 @@ static void CheckIfTrainNeedsService(Vehicle *v) { - const Depot* depot; - TrainFindDepotData tfdd; - if (_patches.servint_trains == 0) return; if (!VehicleNeedsService(v)) return; if (v->vehstatus & VS_STOPPED) return; @@ -3560,7 +3420,7 @@ return; } - tfdd = FindClosestTrainDepot(v, MAX_ACCEPTABLE_DEPOT_DIST); + TrainFindDepotData tfdd = FindClosestTrainDepot(v, MAX_ACCEPTABLE_DEPOT_DIST); /* Only go to the depot if it is not too far out of our way. */ if (tfdd.best_length == (uint)-1 || tfdd.best_length > MAX_ACCEPTABLE_DEPOT_DIST) { if (v->current_order.type == OT_GOTO_DEPOT) { @@ -3574,7 +3434,7 @@ return; } - depot = GetDepotByTile(tfdd.tile); + const Depot* depot = GetDepotByTile(tfdd.tile); if (v->current_order.type == OT_GOTO_DEPOT && v->current_order.dest != depot->index && @@ -3604,8 +3464,6 @@ void OnNewDay_Train(Vehicle *v) { - TileIndex tile; - if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v); if (IsFrontEngine(v)) { @@ -3617,9 +3475,9 @@ CheckOrders(v); /* update destination */ - if (v->current_order.type == OT_GOTO_STATION && - (tile = GetStation(v->current_order.dest)->train_tile) != 0) { - v->dest_tile = tile; + if (v->current_order.type == OT_GOTO_STATION) { + TileIndex tile = GetStation(v->current_order.dest)->train_tile; + if (tile != 0) v->dest_tile = tile; } if ((v->vehstatus & VS_STOPPED) == 0) { @@ -3643,7 +3501,6 @@ FOR_ALL_VEHICLES(v) { if (v->type == VEH_Train && IsFrontEngine(v)) { - // show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) if (_patches.train_income_warn && v->owner == _local_player && v->age >= 730 && v->profit_this_year < 0) { SetDParam(1, v->profit_this_year); @@ -3696,25 +3553,19 @@ u->spritenum--; } - { - Vehicle *w; - - for (w = u->next; w != NULL && (w->engine_type != u->engine_type || w->u.rail.other_multiheaded_part != NULL); w = GetNextVehicle(w)); - if (w != NULL) { - /* we found a car to partner with this engine. Now we will make sure it face the right way */ - if (IsTrainEngine(w)) { - ClearTrainEngine(w); - w->spritenum++; - } + Vehicle *w; + for (w = u->next; w != NULL && (w->engine_type != u->engine_type || w->u.rail.other_multiheaded_part != NULL); w = GetNextVehicle(w)); + if (w != NULL) { + /* we found a car to partner with this engine. Now we will make sure it face the right way */ + if (IsTrainEngine(w)) { + ClearTrainEngine(w); + w->spritenum++; } - - if (w != NULL) { - w->u.rail.other_multiheaded_part = u; - u->u.rail.other_multiheaded_part = w; - } else { - /* we got a front car and no rear cars. We will fake this one for forget that it should have been multiheaded */ - ClearMultiheaded(u); - } + w->u.rail.other_multiheaded_part = u; + u->u.rail.other_multiheaded_part = w; + } else { + /* we got a front car and no rear cars. We will fake this one for forget that it should have been multiheaded */ + ClearMultiheaded(u); } } } END_ENUM_WAGONS(u) diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/tree_cmd.cpp --- a/src/tree_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/tree_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -228,8 +228,8 @@ ey = TileY(tile); sx = TileX(p2); sy = TileY(p2); - if (ex < sx) intswap(ex, sx); - if (ey < sy) intswap(ey, sy); + if (ex < sx) Swap(ex, sx); + if (ey < sy) Swap(ey, sy); cost = 0; // total cost @@ -237,8 +237,6 @@ for (y = sy; y <= ey; y++) { TileIndex tile = TileXY(x, y); - if (!EnsureNoVehicle(tile)) continue; - switch (GetTileType(tile)) { case MP_TREES: // no more space for trees? diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/tunnelbridge_cmd.cpp --- a/src/tunnelbridge_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/tunnelbridge_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,6 +1,6 @@ /* $Id$ */ -/** @file tunnelbridge_cmd.c +/** @file tunnelbridge_cmd.cpp * This file deals with tunnels and bridges (non-gui stuff) * @todo seperate this file into two */ @@ -218,10 +218,10 @@ if (x == sx) { if (y == sy) return_cmd_error(STR_5008_CANNOT_START_AND_END_ON); direction = AXIS_Y; - if (y > sy) uintswap(y,sy); + if (y > sy) Swap(y, sy); } else if (y == sy) { direction = AXIS_X; - if (x > sx) uintswap(x,sx); + if (x > sx) Swap(x, sx); } else { return_cmd_error(STR_500A_START_AND_END_MUST_BE_IN); } @@ -1051,21 +1051,6 @@ } -uint SetSpeedLimitOnBridge(Vehicle *v) -{ - uint bridge_speed; - if (v->vehstatus & VS_HIDDEN) return v->max_speed; /* in tunnel */ - - bridge_speed = _bridge[GetBridgeType(v->tile)].speed; - - if (v->type == VEH_Road) bridge_speed *= 2; /* XXX give vehicles proper speeds */ - - if (v->cur_speed > bridge_speed) v->cur_speed = bridge_speed; - return bridge_speed; -} - - - static uint GetSlopeZ_TunnelBridge(TileIndex tile, uint x, uint y) { uint z; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/variables.h --- a/src/variables.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/variables.h Wed Feb 28 00:33:40 2007 +0000 @@ -337,19 +337,6 @@ VARDEF char *_highscore_file; VARDEF char *_log_file; -// NOSAVE: These can be recalculated from InitializeLandscapeVariables -typedef struct { - StringID names_s[NUM_CARGO]; - StringID names_long[NUM_CARGO]; - StringID names_short[NUM_CARGO]; - byte weights[NUM_CARGO]; - SpriteID sprites[NUM_CARGO]; - byte transit_days_1[NUM_CARGO]; - byte transit_days_2[NUM_CARGO]; -} CargoConst; - -VARDEF CargoConst _cargoc; - static inline void SetDParamX(uint32 *s, uint n, uint32 v) { diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/vehicle.cpp --- a/src/vehicle.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/vehicle.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -37,6 +37,7 @@ #include "newgrf_engine.h" #include "newgrf_sound.h" #include "helpers.hpp" +#include "cargotype.h" #define INVALID_COORD (-0x8000) #define GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6)) @@ -180,8 +181,8 @@ /* Make sure x1 < x2 or y1 < y2 */ if (x1 > x2 || y1 > y2) { - intswap(x1,x2); - intswap(y1,y2); + Swap(x1, x2); + Swap(y1, y2); } FOR_ALL_VEHICLES(veh) { if (without_crashed && (veh->vehstatus & VS_CRASHED) != 0) continue; @@ -761,8 +762,7 @@ */ bool CanRefitTo(EngineID engine_type, CargoID cid_to) { - CargoID cid = _global_cargo_id[_opt_ptr->landscape][cid_to]; - return HASBIT(EngInfo(engine_type)->refit_mask, cid); + return HASBIT(EngInfo(engine_type)->refit_mask, cid_to); } /** Find the first cargo type that an engine can be refitted to. @@ -771,12 +771,11 @@ */ CargoID FindFirstRefittableCargo(EngineID engine_type) { - CargoID cid; uint32 refit_mask = EngInfo(engine_type)->refit_mask; if (refit_mask != 0) { - for (cid = CT_PASSENGERS; cid < NUM_CARGO; cid++) { - if (HASBIT(refit_mask, _global_cargo_id[_opt_ptr->landscape][cid])) return cid; + for (CargoID cid = CT_PASSENGERS; cid < NUM_CARGO; cid++) { + if (HASBIT(refit_mask, cid)) return cid; } } @@ -1848,11 +1847,18 @@ if (flags & DC_EXEC) { w = GetVehicle(_new_vehicle_id); - if (v->cargo_type != w->cargo_type || v->cargo_subtype != w->cargo_subtype) { - // we can't pay for refitting because we can't estimate refitting costs for a vehicle before it's build - // if we pay for it anyway, the cost and the estimated cost will not be the same and we will have an assert - DoCommand(0, w->index, v->cargo_type | (v->cargo_subtype << 8), flags, GetCmdRefitVeh(v)); - } + Vehicle *w2 = w; + Vehicle *v2 = v; + do { + if (v2->cargo_type != w2->cargo_type || v2->cargo_subtype != w2->cargo_subtype) { + /* We can't pay for refitting because we can't estimate refitting costs for a vehicle before it's build. + * If we pay for it anyway, the cost and the estimated cost will not be the same and we will have an assert. + * We need to check the whole chain if it is a train because some newgrf articulated engines can refit some units only (and not the front) */ + DoCommand(0, w->index, v2->cargo_type | (v2->cargo_subtype << 8), flags, GetCmdRefitVeh(v)); + break; // We learned that the engine in question needed a refit. No need to check anymore + } + } while (v->type == VEH_Train && (w2 = w2->next) != NULL && (v2 = v2->next) != NULL); + if (v->type == VEH_Train && HASBIT(v->u.rail.flags, VRF_REVERSE_DIRECTION)) { SETBIT(w->u.rail.flags, VRF_REVERSE_DIRECTION); } @@ -2686,7 +2692,7 @@ } /* returns true if staying in the same tile */ -bool GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp) +GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v) { static const int8 _delta_coord[16] = { -1,-1,-1, 0, 1, 1, 1, 0, /* x */ @@ -2696,11 +2702,12 @@ int x = v->x_pos + _delta_coord[v->direction]; int y = v->y_pos + _delta_coord[v->direction + 8]; - gp->x = x; - gp->y = y; - gp->old_tile = v->tile; - gp->new_tile = TileVirtXY(x, y); - return gp->old_tile == gp->new_tile; + GetNewVehiclePosResult gp; + gp.x = x; + gp.y = y; + gp.old_tile = v->tile; + gp.new_tile = TileVirtXY(x, y); + return gp; } static const Direction _new_direction_table[] = { diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/vehicle.h --- a/src/vehicle.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/vehicle.h Wed Feb 28 00:33:40 2007 +0000 @@ -427,7 +427,7 @@ Trackdir GetVehicleTrackdir(const Vehicle* v); /* returns true if staying in the same tile */ -bool GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp); +GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v); Direction GetDirectionTowards(const Vehicle* v, int x, int y); #define BEGIN_ENUM_WAGONS(v) do { diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/vehicle_gui.cpp --- a/src/vehicle_gui.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/vehicle_gui.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -28,6 +28,7 @@ #include "roadveh.h" #include "depot.h" #include "helpers.hpp" +#include "cargotype.h" typedef struct Sorting { Listing aircraft; @@ -198,7 +199,6 @@ uint i; do { - CargoID cid; uint32 cmask = EngInfo(u->engine_type)->refit_mask; byte callbackmask = EngInfo(u->engine_type)->callbackmask; @@ -206,14 +206,9 @@ if (u->cargo_cap == 0) continue; /* Loop through all cargos in the refit mask */ - for (cid = 0; cmask != 0 && num_lines < max_lines; cmask >>= 1, cid++) { - CargoID lcid; - + for (CargoID cid = 0; cid != NUM_CARGO && num_lines < max_lines; cid++) { /* Skip cargo type if it's not listed */ - if (!HASBIT(cmask, 0)) continue; - - lcid = _local_cargo_id_ctype[cid]; - if (lcid == CT_INVALID) continue; + if (!HASBIT(cmask, cid)) continue; /* Check the vehicle's callback mask for cargo suffixes */ if (HASBIT(callbackmask, CBM_CARGO_SUFFIX)) { @@ -223,7 +218,7 @@ byte temp_subtype = u->cargo_subtype; byte refit_cyc; - u->cargo_type = lcid; + u->cargo_type = cid; for (refit_cyc = 0; refit_cyc < 16 && num_lines < max_lines; refit_cyc++) { bool duplicate = false; @@ -237,12 +232,12 @@ /* Check if this cargo and subtype combination are listed */ for (i = 0; i < num_lines && !duplicate; i++) { - if (refit[i].cargo == lcid && refit[i].value == callback) duplicate = true; + if (refit[i].cargo == cid && refit[i].value == callback) duplicate = true; } if (duplicate) continue; - refit[num_lines].cargo = lcid; + refit[num_lines].cargo = cid; refit[num_lines].subtype = refit_cyc; refit[num_lines].value = callback; refit[num_lines].engine = u->engine_type; @@ -257,11 +252,11 @@ bool duplicate = false; for (i = 0; i < num_lines && !duplicate; i++) { - if (refit[i].cargo == lcid && refit[i].value == CALLBACK_FAILED) duplicate = true; + if (refit[i].cargo == cid && refit[i].value == CALLBACK_FAILED) duplicate = true; } if (!duplicate) { - refit[num_lines].cargo = lcid; + refit[num_lines].cargo = cid; refit[num_lines].subtype = 0; refit[num_lines].value = CALLBACK_FAILED; refit[num_lines].engine = INVALID_ENGINE; @@ -301,7 +296,7 @@ if (i >= pos && i < pos + rows) { /* Draw the cargo name */ - int last_x = DrawString(2, y, _cargoc.names_s[refit[i].cargo], colour); + int last_x = DrawString(2, y, GetCargo(refit[i].cargo)->name, colour); /* If the callback succeeded, draw the cargo suffix */ if (refit[i].value != CALLBACK_FAILED) { @@ -343,15 +338,11 @@ WP(w,refit_d).cargo = DrawVehicleRefitWindow(WP(w, refit_d).list, WP(w, refit_d).sel, w->vscroll.pos, w->vscroll.cap, w->resize.step_height); if (WP(w,refit_d).cargo != NULL) { - int32 cost = 0; - switch (GetVehicle(w->window_number)->type) { - case VEH_Train: cost = CMD_REFIT_RAIL_VEHICLE; break; - case VEH_Road: cost = CMD_REFIT_ROAD_VEH; break; - case VEH_Ship: cost = CMD_REFIT_SHIP; break; - case VEH_Aircraft: cost = CMD_REFIT_AIRCRAFT; break; - } + int32 cost; - cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8, DC_QUERY_COST, cost); + cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8, + DC_QUERY_COST, GetCmdRefitVeh(GetVehicle(w->window_number)->type)); + if (!CmdFailed(cost)) { SetDParam(0, WP(w,refit_d).cargo->cargo); SetDParam(1, _returned_refit_capacity); @@ -497,7 +488,7 @@ /* List of cargo types of this engine */ uint32 cmask = EngInfo(engine)->refit_mask; /* List of cargo types available in this climate */ - uint32 lmask = _landscape_global_cargo_mask[_opt.landscape]; + uint32 lmask = _cargo_mask; char *b = _userstring; /* Draw nothing if the engine is not refittable */ @@ -509,8 +500,6 @@ /* Engine can be refitted to all types in this climate */ b = InlineString(b, STR_PURCHASE_INFO_ALL_TYPES); } else { - CargoID cid; - /* Check if we are able to refit to more cargo types and unable to. If * so, invert the cargo types to list those that we can't refit to. */ if (CountBits(cmask ^ lmask) < CountBits(cmask)) { @@ -518,12 +507,16 @@ b = InlineString(b, STR_PURCHASE_INFO_ALL_BUT); } + bool first = true; + /* Add each cargo type to the list */ - for (cid = 0; cmask != 0; cmask >>= 1, cid++) { - if (!HASBIT(cmask, 0)) continue; + for (CargoID cid = 0; cid < NUM_CARGO; cid++) { + if (!HASBIT(cmask, cid)) continue; - b = InlineString(b, _cargoc.names_s[_local_cargo_id_ctype[cid]]); - if (cmask > 1) b = strecpy(b, ", ", lastof(_userstring)); + if (!first) b = strecpy(b, ", ", lastof(_userstring)); + first = false; + + b = InlineString(b, GetCargo(cid)->name); } } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/video/cocoa_v.h --- a/src/video/cocoa_v.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/video/cocoa_v.h Wed Feb 28 00:33:40 2007 +0000 @@ -10,4 +10,4 @@ extern const HalVideoDriver _cocoa_video_driver; -#endif +#endif /* VIDEO_COCOA_H */ diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/viewport.cpp --- a/src/viewport.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/viewport.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file viewport.cpp */ + #include "stdafx.h" #include "openttd.h" #include "debug.h" @@ -23,7 +25,6 @@ #define VIEWPORT_DRAW_MEM (65536 * 2) -/* viewport.c */ // XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar) static ViewPort _viewports[25 - 2]; static uint32 _active_viewports; ///< bitmasked variable where each bit signifies if a viewport is in use or not @@ -1597,7 +1598,7 @@ { const Sign *si; - if (!(_display_opt & DO_SHOW_SIGNS)) return false; + if (!(_display_opt & DO_SHOW_SIGNS) || _current_player == PLAYER_SPECTATOR) return false; switch (vp->zoom) { case 0: @@ -1883,8 +1884,8 @@ x1 &= ~0xF; y1 &= ~0xF; - if (x1 >= x2) intswap(x1,x2); - if (y1 >= y2) intswap(y1,y2); + if (x1 >= x2) Swap(x1, x2); + if (y1 >= y2) Swap(y1, y2); _thd.new_pos.x = x1; _thd.new_pos.y = y1; _thd.new_size.x = x2 - x1 + TILE_SIZE; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/water_cmd.cpp --- a/src/water_cmd.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/water_cmd.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -3,6 +3,7 @@ #include "stdafx.h" #include "openttd.h" #include "bridge_map.h" +#include "cmd_helper.h" #include "station_map.h" #include "table/sprites.h" #include "table/strings.h" @@ -45,7 +46,7 @@ /** Build a ship depot. * @param tile tile where ship depot is built - * @param p1 depot direction (0 == X or 1 == Y) + * @param p1 bit 0 depot orientation (Axis) * @param p2 unused */ int32 CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) @@ -57,11 +58,11 @@ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - if (p1 > 1) return CMD_ERROR; - if (!EnsureNoVehicle(tile)) return CMD_ERROR; - tile2 = tile + (p1 ? TileDiffXY(0, 1) : TileDiffXY(1, 0)); + Axis axis = Extract(p1); + + tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); if (!EnsureNoVehicle(tile2)) return CMD_ERROR; if (!IsClearWaterTile(tile) || !IsClearWaterTile(tile2)) @@ -84,8 +85,8 @@ depot->xy = tile; depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; - MakeShipDepot(tile, _current_player, DEPOT_NORTH, (Axis)p1); - MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, (Axis)p1); + MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis); + MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis); MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile2); } @@ -229,8 +230,8 @@ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - if (x < sx) intswap(x, sx); - if (y < sy) intswap(y, sy); + if (x < sx) Swap(x, sx); + if (y < sy) Swap(y, sy); size_x = (x - sx) + 1; size_y = (y - sy) + 1; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/win32.cpp --- a/src/win32.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/win32.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file win32.cpp Implementation of MS Windows system calls */ + #include "stdafx.h" #include "hal.h" #include "openttd.h" @@ -653,19 +655,20 @@ } } -DIR *opendir(const char *path) +DIR *opendir(const wchar_t *path) { DIR *d; UINT sem = SetErrorMode(SEM_FAILCRITICALERRORS); // disable 'no-disk' message box - DWORD fa = GetFileAttributesW(OTTD2FS(path)); + DWORD fa = GetFileAttributesW(path); if ((fa != INVALID_FILE_ATTRIBUTES) && (fa & FILE_ATTRIBUTE_DIRECTORY)) { d = dir_calloc(); if (d != NULL) { - char search_path[MAX_PATH]; + wchar_t search_path[MAX_PATH]; /* build search path for FindFirstFile */ - snprintf(search_path, lengthof(search_path), "%s" PATHSEP "*", path); - d->hFind = FindFirstFileW(OTTD2FS(search_path), &d->fd); + _snwprintf(search_path, lengthof(search_path), L"%s\\*", path); + *lastof(search_path) = '\0'; + d->hFind = FindFirstFileW(search_path, &d->fd); if (d->hFind != INVALID_HANDLE_VALUE || GetLastError() == ERROR_NO_MORE_FILES) { // the directory is empty @@ -865,12 +868,12 @@ int _set_error_mode(int); #endif -#if defined(WINCE) -int APIENTRY WinMain -#else -int APIENTRY _tWinMain -#endif - (HINSTANCE hInstance, HINSTANCE hPrevInstance, +#if defined(WINCE) && !defined(_tWinMain) +/* GCC crosscompiler for WINCE doesn't support wide version */ +# define _tWinMain WinMain +#endif /* WINCE */ + +int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { int argc; @@ -919,12 +922,11 @@ #if defined(WINCE) void GetCurrentDirectoryW(int length, wchar_t *path) { - wchar_t *pDest = NULL; /* Get the name of this module */ GetModuleFileName(NULL, path, length); /* Remove the executable name, this we call CurrentDir */ - pDest = wcsrchr(path, '\\'); + wchar_t *pDest = wcsrchr(path, '\\'); if (pDest != NULL) { int result = pDest - path + 1; path[result] = '\0'; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/win32.h --- a/src/win32.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/win32.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file win32.h declarations of functions for MS windows systems */ + #ifndef WIN32_H #define WIN32_H diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/window.cpp --- a/src/window.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/window.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file window.cpp windowing system, widgets and events */ + #include "stdafx.h" #include #include "openttd.h" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/window.h --- a/src/window.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/window.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file window.h regroups declarations for all windowing system, as well as a few helper functions */ + #ifndef WINDOW_H #define WINDOW_H @@ -55,9 +57,9 @@ * They are used in the same place as the above RESIZE_x flags, Widget visual_flags. * These states are used in exceptions. If nothing is specified, they will indicate * Enabled, visible or unclicked widgets*/ - WIDG_DISABLED = 4, // widget is greyed out, not available - WIDG_HIDDEN = 5, // widget is made invisible - WIDG_LOWERED = 6, // widget is paint lowered, a pressed button in fact + WIDG_DISABLED = 4, ///< widget is greyed out, not available + WIDG_HIDDEN = 5, ///< widget is made invisible + WIDG_LOWERED = 6, ///< widget is paint lowered, a pressed button in fact }; DECLARE_ENUM_AS_BIT_SET(ResizeFlag); @@ -90,7 +92,6 @@ /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/ enum WindowWidgetBehaviours { WWB_PUSHBUTTON = 1 << 5, - WWB_MASK = 0xE0, }; @@ -206,23 +207,23 @@ } mouseover; struct { - bool cont; // continue the search? (default true) - uint16 key; // 16-bit Unicode value of the key - uint16 keycode;// untranslated key (including shift-state) + bool cont; ///< continue the search? (default true) + uint16 key; ///< 16-bit Unicode value of the key + uint16 keycode; ///< untranslated key (including shift-state) } keypress; struct { - int msg; // message to be sent - int wparam; // additional message-specific information - int lparam; // additional message-specific information + int msg; ///< message to be sent + int wparam; ///< additional message-specific information + int lparam; ///< additional message-specific information } message; struct { - PointRaw delta; // delta position against position of last call + PointRaw delta; ///< delta position against position of last call } scroll; struct { - int wheel; // how much was 'wheel'd' + int wheel; ///< how much was 'wheel'd' } wheel; } we; }; @@ -239,14 +240,14 @@ } WindowDesc; enum WindowDefaultFlag { - WDF_STD_TOOLTIPS = 1, /* use standard routine when displaying tooltips */ - WDF_DEF_WIDGET = 2, /* default widget control for some widgets in the on click event */ - WDF_STD_BTN = 4, /* default handling for close and drag widgets (widget no 0 and 1) */ + WDF_STD_TOOLTIPS = 1, ///< use standard routine when displaying tooltips + WDF_DEF_WIDGET = 2, ///< default widget control for some widgets in the on click event + WDF_STD_BTN = 4, ///< default handling for close and drag widgets (widget no 0 and 1) - WDF_UNCLICK_BUTTONS = 16, /* Unclick buttons when the window event times out */ - WDF_STICKY_BUTTON = 32, /* Set window to sticky mode; they are not closed unless closed with 'X' (widget 2) */ - WDF_RESIZABLE = 64, /* A window can be resized */ - WDF_MODAL = 128, /* The window is a modal child of some other window, meaning the parent is 'inactive' */ + WDF_UNCLICK_BUTTONS = 16, ///< Unclick buttons when the window event times out */ + WDF_STICKY_BUTTON = 32, ///< Set window to sticky mode; they are not closed unless closed with 'X' (widget 2) + WDF_RESIZABLE = 64, ///< A window can be resized + WDF_MODAL = 128, ///< The window is a modal child of some other window, meaning the parent is 'inactive' }; /* can be used as x or y coordinates to cause a specific placement */ @@ -258,12 +259,12 @@ }; typedef struct Textbuf { - char *buf; /* buffer in which text is saved */ - uint16 maxlength, maxwidth; /* the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes */ - uint16 length, width; /* the current size of the string. Width specifies screensize in pixels, length is in bytes */ - bool caret; /* is the caret ("_") visible or not */ - uint16 caretpos; /* the current position of the caret in the buffer, in bytes */ - uint16 caretxoffs; /* the current position of the caret in pixels */ + char *buf; ///< buffer in which text is saved + uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes + uint16 length, width; ///< the current size of the string. Width specifies screensize in pixels, length is in bytes + bool caret; ///< is the caret ("_") visible or not + uint16 caretpos; ///< the current position of the caret in the buffer, in bytes + uint16 caretxoffs; ///< the current position of the caret in pixels } Textbuf; #define WP(ptr,str) (*(str*)(ptr)->custom) @@ -277,10 +278,10 @@ } Scrollbar; typedef struct ResizeInfo { - uint width; /* Minimum width and height */ + uint width; ///< Minimum width and height uint height; - uint step_width; /* In how big steps the width and height go */ + uint step_width; ///< In how big steps the width and height go uint step_height; } ResizeInfo; @@ -601,12 +602,12 @@ assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d)); typedef struct { - byte item_count; /* follow_vehicle */ - byte sel_index; /* scrollpos_x */ - byte main_button; /* scrollpos_y */ + byte item_count; ///< follow_vehicle + byte sel_index; ///< scrollpos_x + byte main_button; ///< scrollpos_y byte action_id; - StringID string_id; /* unk30 */ - uint16 checked_items; /* unk32 */ + StringID string_id; ///< unk30 + uint16 checked_items; ///< unk32 byte disabled_items; } menu_d; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d)); @@ -643,7 +644,7 @@ RailTypeByte railtype; AirportFTAClass::Flags flags; } filter; - byte sel_index; // deprecated value, used for 'unified' ship and road + byte sel_index; ///< deprecated value, used for 'unified' ship and road bool descending_sort_order; byte sort_criteria; bool regenerate_list; @@ -657,7 +658,7 @@ byte sel_index[2]; EngineID sel_engine[2]; uint16 count[2]; - bool wagon_btnstate; // true means engine is selected + bool wagon_btnstate; ///< true means engine is selected EngineList list[2]; bool update_left; bool update_right; @@ -717,7 +718,7 @@ } vp_d; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d)); -// vp2_d is the same as vp_d, except for the data_# values.. +/* vp2_d is the same as vp_d, except for the data_# values.. */ typedef struct { VehicleID follow_vehicle; int32 scrollpos_x; @@ -750,24 +751,24 @@ typedef enum SortListFlags { VL_NONE = 0x00, - VL_DESC = 0x01, // sort descending or ascending - VL_RESORT = 0x02, // instruct the code to resort the list in the next loop - VL_REBUILD = 0x04, // create sort-listing to use for qsort and friends + VL_DESC = 0x01, ///< sort descending or ascending + VL_RESORT = 0x02, ///< instruct the code to resort the list in the next loop + VL_REBUILD = 0x04, ///< create sort-listing to use for qsort and friends VL_END = 0x08 } SortListFlags; DECLARE_ENUM_AS_BIT_SET(SortListFlags); typedef struct Listing { - bool order; // Ascending/descending - byte criteria; // Sorting criteria + bool order; ///< Ascending/descending + byte criteria; ///< Sorting criteria } Listing; typedef struct list_d { - uint16 list_length; // length of the list being sorted - byte sort_type; // what criteria to sort on - SortListFlags flags; // used to control sorting/resorting/etc. - uint16 resort_timer; // resort list after a given amount of ticks if set + uint16 list_length; ///< length of the list being sorted + byte sort_type; ///< what criteria to sort on + SortListFlags flags; ///< used to control sorting/resorting/etc. + uint16 resort_timer; ///< resort list after a given amount of ticks if set } list_d; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d)); @@ -793,7 +794,7 @@ assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d)); -/* window.c */ +/* window.cpp */ //void CallWindowEventNP(BaseWindow *w, int event); void CallWindowTickEvent(void); //void SetWindowDirty(const BaseWindow *w); @@ -981,7 +982,7 @@ //void CDECL SetWindowWidgetsHiddenState(BaseWindow *w, bool hidden_stat, int widgets, ...); //void CDECL SetWindowWidgetsLoweredState(BaseWindow *w, bool lowered_stat, int widgets, ...); -/* misc_gui.c*/ +/* misc_gui.cpp */ void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint params[]); static inline void GuiShowTooltips(StringID str) { @@ -993,7 +994,7 @@ BaseWindow *GetCallbackWnd(void); //WindowList::Iterator FindWindowZPosition(const BaseWindow *w); -/* window.c */ +/* window.cpp */ //extern BaseWindow *_z_windows[]; //extern BaseWindow **_last_z_window; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/follow_track.hpp --- a/src/yapf/follow_track.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/follow_track.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file follow_track.hpp Template function for track followers */ + #ifndef FOLLOW_TRACK_HPP #define FOLLOW_TRACK_HPP @@ -171,7 +173,7 @@ // rail transport is possible only on compatible rail types if (IsRailTT()) { - RailType rail_type = GetTileRailType(m_new_tile, TrackdirToTrack(DiagdirToDiagTrackdir(m_exitdir))); + RailType rail_type = GetTileRailType(m_new_tile); if (!HASBIT(m_veh->u.rail.compatible_railtypes, rail_type)) { // incompatible rail type return false; diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/nodelist.hpp --- a/src/yapf/nodelist.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/nodelist.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file nodelist.hpp */ + #ifndef NODELIST_HPP #define NODELIST_HPP diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf.h --- a/src/yapf/yapf.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file yapf.h */ + #ifndef YAPF_H #define YAPF_H diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf.hpp --- a/src/yapf/yapf.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -78,10 +78,10 @@ #include "../misc/hashtable.hpp" #include "../misc/binaryheap.hpp" #include "nodelist.hpp" +#include "follow_track.hpp" #include "yapf_base.hpp" #include "yapf_node.hpp" #include "yapf_common.hpp" -#include "follow_track.hpp" #include "yapf_costbase.hpp" #include "yapf_costcache.hpp" diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_base.hpp --- a/src/yapf/yapf_base.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_base.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,14 +1,12 @@ /* $Id$ */ +/** @file yapf_base.hpp */ + #ifndef YAPF_BASE_HPP #define YAPF_BASE_HPP #include "../debug.h" -#include "../misc/fixedsizearray.hpp" -#include "../misc/blob.hpp" -#include "nodelist.hpp" - extern int _total_pf_time_us; /** CYapfBaseT - A-star type path finder base class. @@ -44,6 +42,7 @@ class CYapfBaseT { public: typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class) + typedef typename Types::TrackFollower TrackFollower; typedef typename Types::NodeList NodeList; ///< our node list typedef typename NodeList::Titem Node; ///< this will be our node type typedef typename Node::Key Key; ///< key to hash tables @@ -134,7 +133,7 @@ } } - bool bDestFound = (m_pBestDestNode != NULL); + bool bDestFound = (m_pBestDestNode != NULL) && (m_pBestDestNode != m_pBestIntermediateNode); #ifndef NO_DEBUG_MESSAGES perf.Stop(); @@ -190,20 +189,20 @@ } /** add multiple nodes - direct children of the given node */ - FORCEINLINE void AddMultipleNodes(Node* parent, TileIndex tile, TrackdirBits td_bits) + FORCEINLINE void AddMultipleNodes(Node* parent, const TrackFollower &tf) { - bool is_choice = (KillFirstBit2x64(td_bits) != 0); - for (TrackdirBits rtds = td_bits; rtds != TRACKDIR_BIT_NONE; rtds = (TrackdirBits)KillFirstBit2x64(rtds)) { + bool is_choice = (KillFirstBit2x64(tf.m_new_td_bits) != 0); + for (TrackdirBits rtds = tf.m_new_td_bits; rtds != TRACKDIR_BIT_NONE; rtds = (TrackdirBits)KillFirstBit2x64(rtds)) { Trackdir td = (Trackdir)FindFirstBit2x64(rtds); Node& n = Yapf().CreateNewNode(); - n.Set(parent, tile, td, is_choice); - Yapf().AddNewNode(n); + n.Set(parent, tf.m_new_tile, td, is_choice); + Yapf().AddNewNode(n, tf); } } /** AddNewNode() - called by Tderived::PfFollowNode() for each child node. * Nodes are evaluated here and added into open list */ - void AddNewNode(Node& n) + void AddNewNode(Node &n, const TrackFollower &tf) { // evaluate the node bool bCached = Yapf().PfNodeCacheFetch(n); @@ -213,7 +212,7 @@ m_stats_cache_hits++; } - bool bValid = Yapf().PfCalcCost(n); + bool bValid = Yapf().PfCalcCost(n, tf); if (bCached) { Yapf().PfNodeCacheFlush(n); diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_common.hpp --- a/src/yapf/yapf_common.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_common.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file yapf_common.hpp */ + #ifndef YAPF_COMMON_HPP #define YAPF_COMMON_HPP diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_costcache.hpp --- a/src/yapf/yapf_costcache.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_costcache.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,4 +1,7 @@ /* $Id$ */ + +/** @file yapf_costcache.hpp */ + #ifndef YAPF_COSTCACHE_HPP #define YAPF_COSTCACHE_HPP diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_costrail.hpp --- a/src/yapf/yapf_costrail.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_costrail.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file yapf_costrail.hpp */ + #ifndef YAPF_COSTRAIL_HPP #define YAPF_COSTRAIL_HPP @@ -64,7 +66,7 @@ } /** return one tile cost. If tile is a tunnel entry, it is moved to the end of tunnel */ - FORCEINLINE int OneTileCost(TileIndex& tile, Trackdir trackdir) + FORCEINLINE int OneTileCost(TileIndex prev_tile, TileIndex& tile, Trackdir trackdir) { int cost = 0; // set base cost @@ -77,11 +79,6 @@ cost += Yapf().PfGetSettings().rail_crossing_penalty; break; - case MP_STATION: - // penalty for passing station tiles - cost += Yapf().PfGetSettings().rail_station_penalty; - break; - default: break; } @@ -176,7 +173,7 @@ /** Called by YAPF to calculate the cost from the origin to the given node. * Calculates only the cost of given node, adds it to the parent node cost * and stores the result into Node::m_cost member */ - FORCEINLINE bool PfCalcCost(Node& n) + FORCEINLINE bool PfCalcCost(Node &n, const TrackFollower &tf) { assert(!n.flags_u.flags_s.m_targed_seen); CPerfStart perf_cost(Yapf().m_perf_cost); @@ -195,12 +192,17 @@ Trackdir trackdir = n.m_key.m_td; TileType tile_type = GetTileType(tile); - RailType rail_type = GetTileRailType(tile, TrackdirToTrack(trackdir)); + RailType rail_type = GetTileRailType(tile); bool target_seen = Yapf().PfDetectDestination(tile, trackdir); + if (tf.m_is_station) { + // station tiles have an extra penalty + segment_cost += Yapf().PfGetSettings().rail_station_penalty * (tf.m_tiles_skipped + 1); + } + while (true) { - segment_cost += Yapf().OneTileCost(tile, trackdir); + segment_cost += Yapf().OneTileCost(prev_tile, tile, trackdir); segment_cost += Yapf().CurveCost(prev_trackdir, trackdir); segment_cost += Yapf().SlopeCost(tile, trackdir); segment_cost += Yapf().SignalCost(n, tile, trackdir); @@ -252,7 +254,7 @@ // if tail type changes, finish segment (cached segment can't contain more rail types) { - RailType new_rail_type = GetTileRailType(F.m_new_tile, TrackdirToTrack(FindFirstTrackdir(F.m_new_td_bits))); + RailType new_rail_type = GetTileRailType(F.m_new_tile); if (new_rail_type != rail_type) { break; } diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_destrail.hpp --- a/src/yapf/yapf_destrail.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_destrail.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file yapf_destrail.hpp */ + #ifndef YAPF_DESTRAIL_HPP #define YAPF_DESTRAIL_HPP diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_node.hpp --- a/src/yapf/yapf_node.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_node.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file yapf_node.hpp */ + #ifndef YAPF_NODE_HPP #define YAPF_NODE_HPP diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_node_rail.hpp --- a/src/yapf/yapf_node_rail.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_node_rail.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file yapf_node_rail.hpp */ + #ifndef YAPF_NODE_RAIL_HPP #define YAPF_NODE_RAIL_HPP diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_node_road.hpp --- a/src/yapf/yapf_node_road.hpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_node_road.hpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file yapf_node_road.hpp */ + #ifndef YAPF_NODE_ROAD_HPP #define YAPF_NODE_ROAD_HPP diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_rail.cpp --- a/src/yapf/yapf_rail.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_rail.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file yapf_rail.cpp */ + #include "../stdafx.h" #include "yapf.hpp" @@ -34,7 +36,7 @@ { TrackFollower F(Yapf().GetVehicle()); if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir())) - Yapf().AddMultipleNodes(&old_node, F.m_new_tile, F.m_new_td_bits); + Yapf().AddMultipleNodes(&old_node, F); } /// return debug report character to identify the transportation type @@ -97,7 +99,7 @@ { TrackFollower F(Yapf().GetVehicle()); if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir())) - Yapf().AddMultipleNodes(&old_node, F.m_new_tile, F.m_new_td_bits); + Yapf().AddMultipleNodes(&old_node, F); } /// return debug report character to identify the transportation type diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_road.cpp --- a/src/yapf/yapf_road.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_road.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file yapf_road.cpp */ + #include "../stdafx.h" #include "yapf.hpp" @@ -70,7 +72,7 @@ /** Called by YAPF to calculate the cost from the origin to the given node. * Calculates only the cost of given node, adds it to the parent node cost * and stores the result into Node::m_cost member */ - FORCEINLINE bool PfCalcCost(Node& n) + FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower &tf) { int segment_cost = 0; // start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment @@ -244,7 +246,7 @@ { TrackFollower F(Yapf().GetVehicle()); if (F.Follow(old_node.m_segment_last_tile, old_node.m_segment_last_td)) - Yapf().AddMultipleNodes(&old_node, F.m_new_tile, F.m_new_td_bits); + Yapf().AddMultipleNodes(&old_node, F); } /// return debug report character to identify the transportation type diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_settings.h --- a/src/yapf/yapf_settings.h Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_settings.h Wed Feb 28 00:33:40 2007 +0000 @@ -1,4 +1,7 @@ /* $Id$ */ + +/** @file yapf_settings.h */ + #if !defined(YAPF_SETTINGS_H) || defined(YS_DEF) # ifndef YAPF_SETTINGS_H diff -r 7c8ec33959b1 -r 4b5241e5dd10 src/yapf/yapf_ship.cpp --- a/src/yapf/yapf_ship.cpp Tue Feb 27 23:54:28 2007 +0000 +++ b/src/yapf/yapf_ship.cpp Wed Feb 28 00:33:40 2007 +0000 @@ -1,5 +1,7 @@ /* $Id$ */ +/** @file yapf_ship.cpp */ + #include "../stdafx.h" #include "yapf.hpp" @@ -26,7 +28,7 @@ { TrackFollower F; if (F.Follow(old_node.m_key.m_tile, old_node.m_key.m_td)) - Yapf().AddMultipleNodes(&old_node, F.m_new_tile, F.m_new_td_bits); + Yapf().AddMultipleNodes(&old_node, F); } /// return debug report character to identify the transportation type @@ -86,6 +88,7 @@ { public: typedef typename Types::Tpf Tpf; ///< the pathfinder class (derived from THIS class) + typedef typename Types::TrackFollower TrackFollower; typedef typename Types::NodeList::Titem Node; ///< this will be our node type typedef typename Node::Key Key; ///< key to hash tables @@ -97,7 +100,7 @@ /** Called by YAPF to calculate the cost from the origin to the given node. * Calculates only the cost of given node, adds it to the parent node cost * and stores the result into Node::m_cost member */ - FORCEINLINE bool PfCalcCost(Node& n) + FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower &tf) { // base tile cost depending on distance int c = IsDiagonalTrackdir(n.GetTrackdir()) ? 10 : 7;