diff --git a/config.lib b/config.lib index 1239d9e657..536d58b940 100644 --- a/config.lib +++ b/config.lib @@ -77,6 +77,7 @@ set_default() { enable_builtin_depend="1" with_makedepend="0" with_direct_music="1" + with_xaudio2="1" with_sort="1" with_iconv="1" with_midi="" @@ -155,6 +156,7 @@ set_default() { enable_builtin_depend with_makedepend with_direct_music + with_xaudio2 with_sort with_iconv with_midi @@ -417,6 +419,10 @@ detect_params() { --without-direct-music) with_direct_music="0";; --with-direct-music=*) with_direct_music="$optarg";; + --with-xaudio2) with_xaudio2="2";; + --without-xaudio2) with_xaudio2="0";; + --with-xaudio2=*) with_xaudio2="$optarg";; + --with-sort) with_sort="2";; --without-sort) with_sort="0";; --with-sort=*) with_sort="$optarg";; @@ -895,6 +901,20 @@ check_params() { fi fi + if [ "$with_xaudio2" != "0" ]; then + if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then + if [ "$with_xaudio2" != "1" ]; then + log 1 "configure: error: xaudio2 is only supported on Win32 targets" + exit 1 + fi + with_xaudio2="0" + + log 1 "checking xaudio2... not Windows, skipping" + else + check_xaudio2 + fi + fi + detect_sort # Suppress language errors when there is a version defined, indicating a release @@ -2074,6 +2094,10 @@ EOL fi fi + if [ "$with_xaudio2" != "0" ]; then + CFLAGS="$CFLAGS -DWITH_XAUDIO2" + fi + if [ -n "$libtimidity_config" ]; then CFLAGS="$CFLAGS -DLIBTIMIDITY" CFLAGS="$CFLAGS `$libtimidity_config --cflags | tr '\n\r' ' '`" @@ -2473,6 +2497,35 @@ check_direct_music() { fi } +check_xaudio2() { + echo " + #include + + #undef NTDDI_VERSION + #undef _WIN32_WINNT + + #define NTDDI_VERSION NTDDI_WIN8 + #define _WIN32_WINNT _WIN32_WINNT_WIN8 + + #include + int main(int argc, char *argv[]) { }" > xaudio2.test.c + $cxx_host $CFLAGS xaudio2.test.c -o xaudio2.test 2> /dev/null + res=$? + rm -f xaudio2.test.c xaudio2.test + + if [ "$res" != "0" ]; then + if [ "$with_xaudio2" != "1" ]; then + log 1 "configure: error: xaudio2 is not available on this system" + exit 1 + fi + with_xaudio2="0" + + log 1 "checking xaudio2... not found" + else + log 1 "checking xaudio2... found" + fi +} + check_makedepend() { if [ "$enable_builtin_depend" != "0" ]; then with_makedepend="0" diff --git a/projects/openttd_vs100.vcxproj b/projects/openttd_vs100.vcxproj index 602bd782c9..cf29b3377a 100644 --- a/projects/openttd_vs100.vcxproj +++ b/projects/openttd_vs100.vcxproj @@ -102,7 +102,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -162,7 +162,7 @@ /MP %(AdditionalOptions) Disabled ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -216,7 +216,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -274,7 +274,7 @@ /MP %(AdditionalOptions) Disabled ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -716,6 +716,7 @@ + @@ -1352,6 +1353,7 @@ + diff --git a/projects/openttd_vs100.vcxproj.filters b/projects/openttd_vs100.vcxproj.filters index 5310085f83..5fe2ac6f1b 100644 --- a/projects/openttd_vs100.vcxproj.filters +++ b/projects/openttd_vs100.vcxproj.filters @@ -1308,6 +1308,9 @@ Header Files + + Header Files + Header Files @@ -3216,6 +3219,9 @@ Sound + + Sound + Windows files diff --git a/projects/openttd_vs100.vcxproj.in b/projects/openttd_vs100.vcxproj.in index ab2ae133af..76db416679 100644 --- a/projects/openttd_vs100.vcxproj.in +++ b/projects/openttd_vs100.vcxproj.in @@ -102,7 +102,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -162,7 +162,7 @@ /MP %(AdditionalOptions) Disabled ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -216,7 +216,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -274,7 +274,7 @@ /MP %(AdditionalOptions) Disabled ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug diff --git a/projects/openttd_vs140.vcxproj b/projects/openttd_vs140.vcxproj index 2d39af7961..a6085d0b5c 100644 --- a/projects/openttd_vs140.vcxproj +++ b/projects/openttd_vs140.vcxproj @@ -105,7 +105,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -170,7 +170,7 @@ Disabled true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -228,7 +228,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -291,7 +291,7 @@ Disabled true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -737,6 +737,7 @@ + @@ -1373,6 +1374,7 @@ + diff --git a/projects/openttd_vs140.vcxproj.filters b/projects/openttd_vs140.vcxproj.filters index 5310085f83..5fe2ac6f1b 100644 --- a/projects/openttd_vs140.vcxproj.filters +++ b/projects/openttd_vs140.vcxproj.filters @@ -1308,6 +1308,9 @@ Header Files + + Header Files + Header Files @@ -3216,6 +3219,9 @@ Sound + + Sound + Windows files diff --git a/projects/openttd_vs140.vcxproj.in b/projects/openttd_vs140.vcxproj.in index 1e490d29e7..93debc8672 100644 --- a/projects/openttd_vs140.vcxproj.in +++ b/projects/openttd_vs140.vcxproj.in @@ -105,7 +105,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -170,7 +170,7 @@ Disabled true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -228,7 +228,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -291,7 +291,7 @@ Disabled true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug diff --git a/projects/openttd_vs141.vcxproj b/projects/openttd_vs141.vcxproj index f9b3d58a26..791e8042ce 100644 --- a/projects/openttd_vs141.vcxproj +++ b/projects/openttd_vs141.vcxproj @@ -105,7 +105,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -170,7 +170,7 @@ Disabled true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -228,7 +228,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -291,7 +291,7 @@ Disabled true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -737,6 +737,7 @@ + @@ -1373,6 +1374,7 @@ + diff --git a/projects/openttd_vs141.vcxproj.filters b/projects/openttd_vs141.vcxproj.filters index 5310085f83..5fe2ac6f1b 100644 --- a/projects/openttd_vs141.vcxproj.filters +++ b/projects/openttd_vs141.vcxproj.filters @@ -1308,6 +1308,9 @@ Header Files + + Header Files + Header Files @@ -3216,6 +3219,9 @@ Sound + + Sound + Windows files diff --git a/projects/openttd_vs141.vcxproj.in b/projects/openttd_vs141.vcxproj.in index f4ec557c60..dc6dcd17f9 100644 --- a/projects/openttd_vs141.vcxproj.in +++ b/projects/openttd_vs141.vcxproj.in @@ -105,7 +105,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -170,7 +170,7 @@ Disabled true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -228,7 +228,7 @@ Size true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -291,7 +291,7 @@ Disabled true ..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;WITH_XAUDIO2;WITH_SSE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU_SORT;WITH_ICU_LAYOUT;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj index 5f33377719..ac79ce3581 100644 --- a/projects/openttd_vs80.vcproj +++ b/projects/openttd_vs80.vcproj @@ -2050,6 +2050,10 @@ RelativePath=".\..\src\window_type.h" > + + @@ -4710,6 +4714,10 @@ RelativePath=".\..\src\sound\win32_s.cpp" > + + + + @@ -4707,6 +4711,10 @@ RelativePath=".\..\src\sound\win32_s.cpp" > + + { virtual ~Aircraft() { this->PreDestructor(); } void MarkDirty(); - void UpdateDeltaXY(Direction direction); + void UpdateDeltaXY(); ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; } bool IsPrimaryVehicle() const { return this->IsNormalAircraft(); } void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const; diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 650a73d900..435aa66fa4 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -43,7 +43,7 @@ #include "safeguards.h" -void Aircraft::UpdateDeltaXY(Direction direction) +void Aircraft::UpdateDeltaXY() { this->x_offs = -1; this->y_offs = -1; @@ -307,10 +307,10 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine * u->engine_type = e->index; v->subtype = (avi->subtype & AIR_CTOL ? AIR_AIRCRAFT : AIR_HELICOPTER); - v->UpdateDeltaXY(INVALID_DIR); + v->UpdateDeltaXY(); u->subtype = AIR_SHADOW; - u->UpdateDeltaXY(INVALID_DIR); + u->UpdateDeltaXY(); v->reliability = e->reliability; v->reliability_spd_dec = e->reliability_spd_dec; @@ -373,7 +373,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine * w->random_bits = VehicleRandomBits(); /* Use rotor's air.state to store the rotor animation frame */ w->state = HRS_ROTOR_STOPPED; - w->UpdateDeltaXY(INVALID_DIR); + w->UpdateDeltaXY(); u->SetNext(w); w->UpdatePosition(); @@ -1429,7 +1429,7 @@ static void AircraftEntersTerminal(Aircraft *v) */ static void AircraftLandAirplane(Aircraft *v) { - v->UpdateDeltaXY(INVALID_DIR); + v->UpdateDeltaXY(); if (!PlayVehicleSound(v, VSE_TOUCHDOWN)) { SndPlayVehicleFx(SND_17_SKID_PLANE, v); @@ -1628,7 +1628,7 @@ static void AircraftEventHandler_TakeOff(Aircraft *v, const AirportFTAClass *apc static void AircraftEventHandler_StartTakeOff(Aircraft *v, const AirportFTAClass *apc) { v->state = ENDTAKEOFF; - v->UpdateDeltaXY(INVALID_DIR); + v->UpdateDeltaXY(); } static void AircraftEventHandler_EndTakeOff(Aircraft *v, const AirportFTAClass *apc) @@ -1641,7 +1641,7 @@ static void AircraftEventHandler_EndTakeOff(Aircraft *v, const AirportFTAClass * static void AircraftEventHandler_HeliTakeOff(Aircraft *v, const AirportFTAClass *apc) { v->state = FLYING; - v->UpdateDeltaXY(INVALID_DIR); + v->UpdateDeltaXY(); /* get the next position to go to, differs per airport */ AircraftNextAirportPos_and_Order(v); @@ -1707,7 +1707,7 @@ static void AircraftEventHandler_Landing(Aircraft *v, const AirportFTAClass *apc static void AircraftEventHandler_HeliLanding(Aircraft *v, const AirportFTAClass *apc) { v->state = HELIENDLANDING; - v->UpdateDeltaXY(INVALID_DIR); + v->UpdateDeltaXY(); } static void AircraftEventHandler_EndLanding(Aircraft *v, const AirportFTAClass *apc) diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp index 3995deca98..0d7164ec55 100644 --- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -152,12 +152,12 @@ static inline uint16 GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_t * @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask * @return bit set of CargoIDs */ -static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, bool include_initial_cargo_type) +static inline CargoTypes GetAvailableVehicleCargoTypes(EngineID engine, bool include_initial_cargo_type) { const Engine *e = Engine::Get(engine); if (!e->CanCarryCargo()) return 0; - uint32 cargoes = e->info.refit_mask; + CargoTypes cargoes = e->info.refit_mask; if (include_initial_cargo_type) { SetBit(cargoes, e->GetDefaultCargoType()); @@ -202,7 +202,7 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine) * @param[out] cargoes Total amount of units that can be transported, summed by cargo. * @param[out] refits Whether a (possibly partial) refit for each cargo is possible. */ -void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, uint32 *refits) +void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, CargoTypes *refits) { cargoes->Clear(); *refits = 0; @@ -261,12 +261,12 @@ bool IsArticulatedVehicleRefittable(EngineID engine) * @param union_mask returns bit mask of CargoIDs which are a refit option for at least one articulated part * @param intersection_mask returns bit mask of CargoIDs which are a refit option for every articulated part (with default capacity > 0) */ -void GetArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type, uint32 *union_mask, uint32 *intersection_mask) +void GetArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type, CargoTypes *union_mask, CargoTypes *intersection_mask) { const Engine *e = Engine::Get(engine); - uint32 veh_cargoes = GetAvailableVehicleCargoTypes(engine, include_initial_cargo_type); + CargoTypes veh_cargoes = GetAvailableVehicleCargoTypes(engine, include_initial_cargo_type); *union_mask = veh_cargoes; - *intersection_mask = (veh_cargoes != 0) ? veh_cargoes : UINT32_MAX; + *intersection_mask = (veh_cargoes != 0) ? veh_cargoes : ALL_CARGOTYPES; if (!e->IsGroundVehicle()) return; if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return; @@ -287,9 +287,9 @@ void GetArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type, * @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask * @return bit mask of CargoIDs which are a refit option for at least one articulated part */ -uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type) +CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type) { - uint32 union_mask, intersection_mask; + CargoTypes union_mask, intersection_mask; GetArticulatedRefitMasks(engine, include_initial_cargo_type, &union_mask, &intersection_mask); return union_mask; } @@ -300,9 +300,9 @@ uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_car * @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask * @return bit mask of CargoIDs which are a refit option for every articulated part (with default capacity > 0) */ -uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type) +CargoTypes GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type) { - uint32 union_mask, intersection_mask; + CargoTypes union_mask, intersection_mask; GetArticulatedRefitMasks(engine, include_initial_cargo_type, &union_mask, &intersection_mask); return intersection_mask; } @@ -347,16 +347,16 @@ void CheckConsistencyOfArticulatedVehicle(const Vehicle *v) { const Engine *engine = v->GetEngine(); - uint32 purchase_refit_union, purchase_refit_intersection; + CargoTypes purchase_refit_union, purchase_refit_intersection; GetArticulatedRefitMasks(v->engine_type, true, &purchase_refit_union, &purchase_refit_intersection); CargoArray purchase_default_capacity = GetCapacityOfArticulatedParts(v->engine_type); - uint32 real_refit_union = 0; - uint32 real_refit_intersection = UINT_MAX; + CargoTypes real_refit_union = 0; + CargoTypes real_refit_intersection = ALL_CARGOTYPES; CargoArray real_default_capacity; do { - uint32 refit_mask = GetAvailableVehicleCargoTypes(v->engine_type, true); + CargoTypes refit_mask = GetAvailableVehicleCargoTypes(v->engine_type, true); real_refit_union |= refit_mask; if (refit_mask != 0) real_refit_intersection &= refit_mask; diff --git a/src/articulated_vehicles.h b/src/articulated_vehicles.h index e1256807d8..8650a280b5 100644 --- a/src/articulated_vehicles.h +++ b/src/articulated_vehicles.h @@ -20,9 +20,9 @@ uint CountArticulatedParts(EngineID engine_type, bool purchase_window); void GetArticulatedPartsEngineIDs(EngineID engine_type, bool purchase_window, std::vector &ids); CargoArray GetCapacityOfArticulatedParts(EngineID engine); void AddArticulatedParts(Vehicle *first); -void GetArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type, uint32 *union_mask, uint32 *intersection_mask); -uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type); -uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type); +void GetArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type, CargoTypes *union_mask, CargoTypes *intersection_mask); +CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type); +CargoTypes GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type); bool IsArticulatedVehicleCarryingDifferentCargoes(const Vehicle *v, CargoID *cargo_type); bool IsArticulatedVehicleRefittable(EngineID engine); bool IsArticulatedEngine(EngineID engine_type); diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index f1b358d9fe..7c06dec04c 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -38,8 +38,8 @@ extern void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index); */ static bool EnginesHaveCargoInCommon(EngineID engine_a, EngineID engine_b) { - uint32 available_cargoes_a = GetUnionOfArticulatedRefitMasks(engine_a, true); - uint32 available_cargoes_b = GetUnionOfArticulatedRefitMasks(engine_b, true); + CargoTypes available_cargoes_a = GetUnionOfArticulatedRefitMasks(engine_a, true); + CargoTypes available_cargoes_b = GetUnionOfArticulatedRefitMasks(engine_b, true); return (available_cargoes_a == 0 || available_cargoes_b == 0 || (available_cargoes_a & available_cargoes_b) != 0); } @@ -174,9 +174,8 @@ static void TransferCargo(Vehicle *old_veh, Vehicle *new_head, bool part_of_chai */ static bool VerifyAutoreplaceRefitForOrders(const Vehicle *v, EngineID engine_type) { - - uint32 union_refit_mask_a = GetUnionOfArticulatedRefitMasks(v->engine_type, false); - uint32 union_refit_mask_b = GetUnionOfArticulatedRefitMasks(engine_type, false); + CargoTypes union_refit_mask_a = GetUnionOfArticulatedRefitMasks(v->engine_type, false); + CargoTypes union_refit_mask_b = GetUnionOfArticulatedRefitMasks(engine_type, false); const Order *o; const Vehicle *u = (v->type == VEH_TRAIN) ? v->First() : v; @@ -202,7 +201,7 @@ static bool VerifyAutoreplaceRefitForOrders(const Vehicle *v, EngineID engine_ty */ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool part_of_chain) { - uint32 available_cargo_types, union_mask; + CargoTypes available_cargo_types, union_mask; GetArticulatedRefitMasks(engine_type, true, &union_mask, &available_cargo_types); if (union_mask == 0) return CT_NO_REFIT; // Don't try to refit an engine with no cargo capacity diff --git a/src/base_station_base.h b/src/base_station_base.h index 1db167ade6..08a66bea56 100644 --- a/src/base_station_base.h +++ b/src/base_station_base.h @@ -71,7 +71,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> { uint16 random_bits; ///< Random bits assigned to this station byte waiting_triggers; ///< Waiting triggers (NewGRF) for this station uint8 cached_anim_triggers; ///< NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen. - uint32 cached_cargo_triggers; ///< NOSAVE: Combined cargo trigger bitmask + CargoTypes cached_cargo_triggers; ///< NOSAVE: Combined cargo trigger bitmask TileArea train_station; ///< Tile area the train 'station' part covers StationRect rect; ///< NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp index d6d936007a..c543faa0dd 100644 --- a/src/blitter/32bpp_anim.cpp +++ b/src/blitter/32bpp_anim.cpp @@ -318,9 +318,7 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height, } Colour *udst = (Colour *)dst; - uint16 *anim; - - anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)dst); + uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)dst); if (pal == PALETTE_TO_TRANSPARENT) { do { @@ -432,9 +430,7 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colou } Colour colour32 = LookupColourInPalette(colour); - uint16 *anim_line; - - anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->anim_buf; + uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->anim_buf; do { Colour *dst = (Colour *)video; @@ -616,8 +612,8 @@ void Blitter_32bppAnim::PostResize() if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) { /* The size of the screen changed; we can assume we can wipe all data from our buffer */ free(this->anim_alloc); - this->anim_buf_height = _screen.height; this->anim_buf_width = _screen.width; + this->anim_buf_height = _screen.height; this->anim_buf_pitch = (_screen.width + 7) & ~7; this->anim_alloc = CallocT(this->anim_buf_pitch * this->anim_buf_height + 8); diff --git a/src/blitter/32bpp_base.cpp b/src/blitter/32bpp_base.cpp index 47e119f067..74ac459059 100644 --- a/src/blitter/32bpp_base.cpp +++ b/src/blitter/32bpp_base.cpp @@ -195,10 +195,10 @@ Colour Blitter_32bppBase::ReallyAdjustBrightness(Colour colour, uint8 brightness /* Reduce overbright strength */ ob /= 2; return Colour( - r >= 255 ? 255 : min(r + ob * (255 - r) / 256, 255), - g >= 255 ? 255 : min(g + ob * (255 - g) / 256, 255), - b >= 255 ? 255 : min(b + ob * (255 - b) / 256, 255), - colour.a); + r >= 255 ? 255 : min(r + ob * (255 - r) / 256, 255), + g >= 255 ? 255 : min(g + ob * (255 - g) / 256, 255), + b >= 255 ? 255 : min(b + ob * (255 - b) / 256, 255), + colour.a); } Blitter::PaletteAnimation Blitter_32bppBase::UsePaletteAnimation() diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 8d200fef60..2d774d3fc4 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -529,7 +529,7 @@ const StringID _engine_sort_listing[][12] = {{ static bool CDECL CargoFilter(const EngineID *eid, const CargoID cid) { if (cid == CF_ANY) return true; - uint32 refit_mask = GetUnionOfArticulatedRefitMasks(*eid, true) & _standard_cargo_mask; + CargoTypes refit_mask = GetUnionOfArticulatedRefitMasks(*eid, true) & _standard_cargo_mask; return (cid == CF_NONE ? refit_mask == 0 : HasBit(refit_mask, cid)); } @@ -540,7 +540,7 @@ static GUIEngineList::FilterFunction * const _filter_funcs[] = { static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine) { CargoArray cap; - uint32 refits; + CargoTypes refits; GetArticulatedVehicleCargoesAndRefits(engine, &cap, &refits); for (CargoID c = 0; c < NUM_CARGO; c++) { diff --git a/src/cargo_type.h b/src/cargo_type.h index 7b7168a102..402e81c1b2 100644 --- a/src/cargo_type.h +++ b/src/cargo_type.h @@ -22,7 +22,7 @@ typedef byte CargoID; /** Available types of cargo */ -enum CargoTypes { +enum CargoType { /* Temperate */ CT_PASSENGERS = 0, CT_COAL = 1, @@ -70,6 +70,10 @@ enum CargoTypes { CT_INVALID = 0xFF, ///< Invalid cargo type. }; +typedef uint32 CargoTypes; + +static const CargoTypes ALL_CARGOTYPES = (CargoTypes)UINT32_MAX; + /** Class for storing amounts of cargo */ struct CargoArray { private: diff --git a/src/cargotype.cpp b/src/cargotype.cpp index 863c585616..6cc02f63a3 100644 --- a/src/cargotype.cpp +++ b/src/cargotype.cpp @@ -28,12 +28,12 @@ CargoSpec CargoSpec::array[NUM_CARGO]; * Bitmask of cargo types available. This includes phony cargoes like regearing cargoes. * Initialized during a call to #SetupCargoForClimate. */ -uint32 _cargo_mask; +CargoTypes _cargo_mask; /** * Bitmask of real cargo types available. Phony cargoes like regearing cargoes are excluded. */ -uint32 _standard_cargo_mask; +CargoTypes _standard_cargo_mask; /** * Set up the default cargo types for the given landscape type. diff --git a/src/cargotype.h b/src/cargotype.h index fee461d7fb..71cd932bbf 100644 --- a/src/cargotype.h +++ b/src/cargotype.h @@ -129,8 +129,8 @@ private: friend void SetupCargoForClimate(LandscapeID l); }; -extern uint32 _cargo_mask; -extern uint32 _standard_cargo_mask; +extern CargoTypes _cargo_mask; +extern CargoTypes _standard_cargo_mask; void SetupCargoForClimate(LandscapeID l); CargoID GetCargoIDByLabel(CargoLabel cl); @@ -156,7 +156,7 @@ static inline bool IsCargoInClass(CargoID c, CargoClass cc) if ((var = CargoSpec::Get(cargospec_index))->IsValid()) #define FOR_ALL_CARGOSPECS(var) FOR_ALL_CARGOSPECS_FROM(var, 0) -#define FOR_EACH_SET_CARGO_ID(var, cargo_bits) FOR_EACH_SET_BIT_EX(CargoID, var, uint, cargo_bits) +#define FOR_EACH_SET_CARGO_ID(var, cargo_bits) FOR_EACH_SET_BIT_EX(CargoID, var, CargoTypes, cargo_bits) /** * Loop header for iterating over cargoes, sorted by name. This includes phony cargoes like regearing cargoes. diff --git a/src/company_base.h b/src/company_base.h index 0f711d1b79..5283ee764d 100644 --- a/src/company_base.h +++ b/src/company_base.h @@ -69,8 +69,6 @@ struct CompanyProperties { byte colour; ///< Company colour. - RailTypes avail_railtypes; ///< Rail types available to the company. - byte block_preview; ///< Number of quarters that the company is not allowed to get new exclusive engine previews (see CompaniesGenStatistics). TileIndex location_of_HQ; ///< Northern tile of HQ; #INVALID_TILE when there is none. @@ -114,6 +112,7 @@ struct Company : CompanyPool::PoolItem<&_company_pool>, CompanyProperties { ~Company(); Livery livery[LS_END]; + RailTypes avail_railtypes; ///< Rail types available to this company. RoadTypes avail_roadtypes; ///< Road types available to this company. class AIInstance *ai_instance; diff --git a/src/disaster_vehicle.cpp b/src/disaster_vehicle.cpp index 8316c542dc..154aca3d9a 100644 --- a/src/disaster_vehicle.cpp +++ b/src/disaster_vehicle.cpp @@ -165,7 +165,7 @@ DisasterVehicle::DisasterVehicle(int x, int y, Direction direction, DisasterSubT this->direction = direction; this->tile = TileVirtXY(x, y); this->subtype = subtype; - this->UpdateDeltaXY(INVALID_DIR); + this->UpdateDeltaXY(); this->owner = OWNER_NONE; this->image_override = 0; this->current_order.Free(); @@ -978,7 +978,7 @@ void ReleaseDisastersTargetingVehicle(VehicleID vehicle) } } -void DisasterVehicle::UpdateDeltaXY(Direction direction) +void DisasterVehicle::UpdateDeltaXY() { this->x_offs = -1; this->y_offs = -1; diff --git a/src/disaster_vehicle.h b/src/disaster_vehicle.h index 06fb36c1e3..e86d96e97d 100644 --- a/src/disaster_vehicle.h +++ b/src/disaster_vehicle.h @@ -48,7 +48,7 @@ struct DisasterVehicle FINAL : public SpecializedVehicle cur_company(_current_company, v->owner, FILE_LINE); - uint32 refit_mask = v->GetEngine()->info.refit_mask; + CargoTypes refit_mask = v->GetEngine()->info.refit_mask; /* Remove old capacity from consist capacity and collect refit mask. */ IterateVehicleParts(v_start, PrepareRefitAction(consist_capleft, refit_mask)); @@ -1746,10 +1746,10 @@ static void LoadUnloadVehicle(Vehicle *front) bool completely_emptied = true; bool anything_unloaded = false; bool anything_loaded = false; - uint32 full_load_amount = 0; - uint32 cargo_not_full = 0; - uint32 cargo_full = 0; - uint32 reservation_left = 0; + CargoTypes full_load_amount = 0; + CargoTypes cargo_not_full = 0; + CargoTypes cargo_full = 0; + CargoTypes reservation_left = 0; front->cur_speed = 0; @@ -1986,7 +1986,7 @@ static void LoadUnloadVehicle(Vehicle *front) /* if the aircraft carries passengers and is NOT full, then * continue loading, no matter how much mail is in */ if ((front->type == VEH_AIRCRAFT && IsCargoInClass(front->cargo_type, CC_PASSENGERS) && front->cargo_cap > front->cargo.StoredCount()) || - (cargo_not_full && (cargo_full & ~cargo_not_full) == 0)) { // There are still non-full cargoes + (cargo_not_full != 0 && (cargo_full & ~cargo_not_full) == 0)) { // There are still non-full cargoes finished_loading = false; } } else if (cargo_not_full != 0) { diff --git a/src/effectvehicle.cpp b/src/effectvehicle.cpp index 4cc886bfbe..3aff4cacdc 100644 --- a/src/effectvehicle.cpp +++ b/src/effectvehicle.cpp @@ -625,7 +625,7 @@ EffectVehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type) v->y_pos = y; v->z_pos = z; v->tile = 0; - v->UpdateDeltaXY(INVALID_DIR); + v->UpdateDeltaXY(); v->vehstatus = VS_UNCLICKABLE; _effect_init_procs[type](v); @@ -669,7 +669,7 @@ bool EffectVehicle::Tick() return _effect_tick_procs[this->subtype](this); } -void EffectVehicle::UpdateDeltaXY(Direction direction) +void EffectVehicle::UpdateDeltaXY() { this->x_offs = 0; this->y_offs = 0; diff --git a/src/effectvehicle_base.h b/src/effectvehicle_base.h index 27da420017..d809657fab 100644 --- a/src/effectvehicle_base.h +++ b/src/effectvehicle_base.h @@ -32,7 +32,7 @@ struct EffectVehicle FINAL : public SpecializedVehicletype != VEH_TRAIN ? GetUnionOfArticulatedRefitMasks(e->index, true) : (uint32)-1; + CargoTypes cargomask = e->type != VEH_TRAIN ? GetUnionOfArticulatedRefitMasks(e->index, true) : ALL_CARGOTYPES; int32 best_hist = -1; const Company *c; @@ -1127,7 +1127,9 @@ bool IsEngineRefittable(EngineID engine) /* Is there any cargo except the default cargo? */ CargoID default_cargo = e->GetDefaultCargoType(); - return default_cargo != CT_INVALID && ei->refit_mask != 1U << default_cargo; + CargoTypes default_cargo_mask = 0; + SetBit(default_cargo_mask, default_cargo); + return default_cargo != CT_INVALID && ei->refit_mask != default_cargo_mask; } /** diff --git a/src/engine_func.h b/src/engine_func.h index 6c3fb14ff2..37fb005092 100644 --- a/src/engine_func.h +++ b/src/engine_func.h @@ -26,7 +26,7 @@ extern const uint8 _engine_offsets[4]; bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company); bool IsEngineRefittable(EngineID engine); -void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, uint32 *refits); +void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, CargoTypes *refits); void SetYearEngineAgingStops(); void StartupOneEngine(Engine *e, Date aging_date); diff --git a/src/engine_type.h b/src/engine_type.h index 8356fda8f8..82f10d9d87 100644 --- a/src/engine_type.h +++ b/src/engine_type.h @@ -137,7 +137,7 @@ struct EngineInfo { byte load_amount; byte climates; ///< Climates supported by the engine. CargoID cargo_type; - uint32 refit_mask; + CargoTypes refit_mask; byte refit_cost; byte misc_flags; ///< Miscellaneous flags. @see EngineMiscFlags byte callback_mask; ///< Bitmask of vehicle callbacks that have to be called diff --git a/src/ground_vehicle.cpp b/src/ground_vehicle.cpp index f82985306c..b1019cac36 100644 --- a/src/ground_vehicle.cpp +++ b/src/ground_vehicle.cpp @@ -91,8 +91,8 @@ void GroundVehicle::CalculatePower(uint32& total_power, uint32& max_te, if (current_power > 0) max_te += u->GetWeight() * u->GetTractiveEffort(); } - max_te *= 10000; // Tractive effort in (tonnes * 1000 * 10 =) N. - max_te /= 256; // Tractive effort is a [0-255] coefficient. + max_te *= 9800; // Tractive effort in (tonnes * 1000 * 9.8 =) N. + max_te /= 256; // Tractive effort is a [0-255] coefficient. } /** diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 0c35799151..1cdcba42dd 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -391,7 +391,7 @@ static Foundation GetFoundation_Industry(TileIndex tile, Slope tileh) return FlatteningFoundation(tileh); } -static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted) +static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted) { IndustryGfx gfx = GetIndustryGfx(tile); const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx); diff --git a/src/lang/dutch.txt b/src/lang/dutch.txt index 0d8c6194bf..1c5d5e6bba 100644 --- a/src/lang/dutch.txt +++ b/src/lang/dutch.txt @@ -476,7 +476,7 @@ STR_ABOUT_MENU_ZOOMIN_SCREENSHOT :Ingezoomd scree STR_ABOUT_MENU_DEFAULTZOOM_SCREENSHOT :Screenshot met standaard zoom STR_ABOUT_MENU_GIANT_SCREENSHOT :Screenshot van hele kaart STR_ABOUT_MENU_ABOUT_OPENTTD :Over 'OpenTTD' -STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite uitlijner +STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite-uitlijner STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Schakel selectiekaders STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Schakel kleuren van braakliggende grond aan/uit ############ range ends here @@ -1144,7 +1144,7 @@ STR_CONFIG_SETTING_RUNNING_COSTS :Onderhoudskoste STR_CONFIG_SETTING_RUNNING_COSTS_HELPTEXT :Het niveau van onderhoud en bedrijfskosten van voertuigen en infrastuctuur STR_CONFIG_SETTING_CONSTRUCTION_SPEED :Bouwsnelheid: {STRING} STR_CONFIG_SETTING_CONSTRUCTION_SPEED_HELPTEXT :Beperk de hoeveelheid bouwactiviteiten voor computerspeler -STR_CONFIG_SETTING_VEHICLE_BREAKDOWNS :Voertuig storingen: {STRING} +STR_CONFIG_SETTING_VEHICLE_BREAKDOWNS :Voertuigstoringen: {STRING} STR_CONFIG_SETTING_VEHICLE_BREAKDOWNS_HELPTEXT :Controle hoe vaak onvoldoende onderhouden voertuigen kapot kunnen gaan STR_CONFIG_SETTING_SUBSIDY_MULTIPLIER :Subsidie indicator: {STRING} STR_CONFIG_SETTING_SUBSIDY_MULTIPLIER_HELPTEXT :Instellen hoeveel wordt betaald voor gesubsidieerde verbindingen diff --git a/src/lang/greek.txt b/src/lang/greek.txt index 67218b86b9..4e7863f538 100644 --- a/src/lang/greek.txt +++ b/src/lang/greek.txt @@ -757,6 +757,7 @@ STR_MUSIC_RULER_MARKER :{TINY_FONT}{BLA STR_MUSIC_TRACK_NONE :{TINY_FONT}{DKGREEN}-- STR_MUSIC_TRACK_DIGIT :{TINY_FONT}{DKGREEN}{ZEROFILL_NUM} STR_MUSIC_TITLE_NONE :{TINY_FONT}{DKGREEN}------ +STR_MUSIC_TITLE_NOMUSIC :{TINY_FONT}{DKGREEN}Δεν υπάρχει διαθέσιμη μουσική STR_MUSIC_TITLE_NAME :{TINY_FONT}{DKGREEN}«{STRING}» STR_MUSIC_TRACK :{TINY_FONT}{BLACK}Κομμάτι STR_MUSIC_XTITLE :{TINY_FONT}{BLACK}Τίτλος @@ -781,7 +782,9 @@ STR_PLAYLIST_TRACK_NAME :{TINY_FONT}{LTB STR_PLAYLIST_TRACK_INDEX :{TINY_FONT}{BLACK}Λίστα σιδηροτροχιών STR_PLAYLIST_PROGRAM :{TINY_FONT}{BLACK}Πρόγραμμα - '{STRING}' STR_PLAYLIST_CLEAR :{TINY_FONT}{BLACK}Καθαρισμός +STR_PLAYLIST_CHANGE_SET :{BLACK}Αλλαγή σετ STR_PLAYLIST_TOOLTIP_CLEAR_CURRENT_PROGRAM_CUSTOM1 :{BLACK}Καθαρισμός τρέχοντος προγράμματος (μόνο Προσαρμοσμένο 1 ή Προσαρμοσμένο 2) +STR_PLAYLIST_TOOLTIP_CHANGE_SET :{BLACK}Αλλαγή μουσικής επιλογής σε άλλο εγκατεστημένο σετ STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Πατήστε στο μουσικό κομμάτι για προσθήκη στο τρέχον πρόγραμμα (Προσαρμοσμένο1 ή Προσαρμοσμένο2 μόνο) STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Πατήστε στο τραγούδι για να το αφαιρέσετε από το πρόγραμμα (Προσαρμοσμένο 1 ή 2 μόνο) @@ -1441,6 +1444,11 @@ STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_HELPTEXT :Χρώμα εδ STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_GREEN :Πράσινο STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_DARK_GREEN :Σκούρο πράσινο STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_VIOLET :Βιολετί +STR_CONFIG_SETTING_SCROLLMODE_HELPTEXT :Συμπεριφορά κατά την κύλιση του χάρτη +STR_CONFIG_SETTING_SCROLLMODE_DEFAULT :Μετακίνηση μικρού χάρτη με ΔΠΠ, θέση ποντικιού κλειδωμένη +STR_CONFIG_SETTING_SCROLLMODE_RMB_LOCKED :Μετακίνηση χάρτη με ΔΠΠ, θέση ποντικιού κλειδωμένη +STR_CONFIG_SETTING_SCROLLMODE_RMB :Μετακίνηση χάρτη με ΔΠΠ +STR_CONFIG_SETTING_SCROLLMODE_LMB :Μετακίνηση χάρτη με ΑΠΠ STR_CONFIG_SETTING_SMOOTH_SCROLLING :Ομαλή μετάβαση οθόνης: {STRING} STR_CONFIG_SETTING_SMOOTH_SCROLLING_HELPTEXT :Ελέγξτε τον τρόπο με τον οποίο η κύρια προβολή κυλίεται σε μια συγκεκριμένη θέση όταν πατάτε πάνω στον μικρό χάρτη ή όταν δίνετε εντολή για μετάβαση σε ένα συγκεκριμένο αντικείμενο στον χάρτη. Όταν είναι ενεργοποιημένη, η κύλιση γίνεται ομαλά, και όταν είναι απενεργοποιημένη μεταβαίνει απ' ευθείας στο επιλεγμένο σημείο STR_CONFIG_SETTING_MEASURE_TOOLTIP :Εμφάνιση εργαλείου μετρήσεως όταν χρησιμοποιούνται διάφορα εργαλεία: {STRING} diff --git a/src/lang/polish.txt b/src/lang/polish.txt index b115ee94ed..a5112a8ec5 100644 --- a/src/lang/polish.txt +++ b/src/lang/polish.txt @@ -1029,6 +1029,7 @@ STR_MUSIC_RULER_MARKER :{TINY_FONT}{BLA STR_MUSIC_TRACK_NONE :{TINY_FONT}{DKGREEN}-- STR_MUSIC_TRACK_DIGIT :{TINY_FONT}{DKGREEN}{ZEROFILL_NUM} STR_MUSIC_TITLE_NONE :{TINY_FONT}{DKGREEN}------ +STR_MUSIC_TITLE_NOMUSIC :{TINY_FONT}{DKGREEN}Brak dostępnej muzyki STR_MUSIC_TITLE_NAME :{TINY_FONT}{DKGREEN}"{STRING}" STR_MUSIC_TRACK :{TINY_FONT}{BLACK}Ścieżka STR_MUSIC_XTITLE :{TINY_FONT}{BLACK}Tytuł @@ -1053,6 +1054,7 @@ STR_PLAYLIST_TRACK_NAME :{TINY_FONT}{LTB STR_PLAYLIST_TRACK_INDEX :{TINY_FONT}{BLACK}Wykaz ścieżek STR_PLAYLIST_PROGRAM :{TINY_FONT}{BLACK}Programuj - '{STRING}' STR_PLAYLIST_CLEAR :{TINY_FONT}{BLACK}Wyczyść +STR_PLAYLIST_CHANGE_SET :{BLACK}Zmień zestaw STR_PLAYLIST_TOOLTIP_CLEAR_CURRENT_PROGRAM_CUSTOM1 :{BLACK}Wyczyść obecny program (tylko Wlasny1 lub Wlasny2) STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Klik na ścieżce aby dodać do obecnego programu (Wlasny1 i Wlasny2) STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Kliknij na ścieżce muzycznej aby usunąć ją z wybranego programu (Wlasny1 lub Wlasny2) @@ -1714,6 +1716,9 @@ STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_HELPTEXT :Kolor terenu na STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_GREEN :zielony STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_DARK_GREEN :ciemnozielony STR_CONFIG_SETTING_SMALLMAP_LAND_COLOUR_VIOLET :fioletowy +STR_CONFIG_SETTING_SCROLLMODE_HELPTEXT :Zachowanie podczas przeciągania mapy +STR_CONFIG_SETTING_SCROLLMODE_RMB :Przeciągnij mapę prawym przyciskiem myszy +STR_CONFIG_SETTING_SCROLLMODE_LMB :Przeciągnij mapę lewym przyciskiem myszy STR_CONFIG_SETTING_SMOOTH_SCROLLING :Wygładź przesuwanie widoku: {STRING} STR_CONFIG_SETTING_SMOOTH_SCROLLING_HELPTEXT :Zdecyduj, jak główny widok przesuwa się do konkretnej lokacji, gdy klikasz na mini-mapie lub gdy używasz komendy do przesunięcia do danego obiektu na mapie. Kiedy włączone, widok przesuwa się płynnie, kiedy wyłączone, następuje skok bezpośrednio do wybranego miejsca STR_CONFIG_SETTING_MEASURE_TOOLTIP :Pokaż dymek z pomiarem podczas używania różnych narzędzi: {STRING} diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 7e74e300ab..21105981cb 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -386,7 +386,7 @@ Point LinkGraphOverlay::GetStationMiddle(const Station *st) const * Set a new cargo mask and rebuild the cache. * @param cargo_mask New cargo mask. */ -void LinkGraphOverlay::SetCargoMask(uint32 cargo_mask) +void LinkGraphOverlay::SetCargoMask(CargoTypes cargo_mask) { this->cargo_mask = cargo_mask; this->RebuildCache(); @@ -523,7 +523,7 @@ void LinkGraphLegendWindow::SetOverlay(LinkGraphOverlay *overlay) { this->SetWidgetLoweredState(WID_LGL_COMPANY_FIRST + c, HasBit(companies, c)); } } - uint32 cargoes = this->overlay->GetCargoMask(); + CargoTypes cargoes = this->overlay->GetCargoMask(); for (uint c = 0; c < NUM_CARGO; c++) { if (!this->IsWidgetDisabled(WID_LGL_CARGO_FIRST + c)) { this->SetWidgetLoweredState(WID_LGL_CARGO_FIRST + c, HasBit(cargoes, c)); @@ -629,7 +629,7 @@ void LinkGraphLegendWindow::UpdateOverlayCompanies() */ void LinkGraphLegendWindow::UpdateOverlayCargoes() { - uint32 mask = 0; + CargoTypes mask = 0; for (uint c = 0; c < NUM_CARGO; c++) { if (this->IsWidgetDisabled(c + WID_LGL_CARGO_FIRST)) continue; if (!this->IsWidgetLowered(c + WID_LGL_CARGO_FIRST)) continue; diff --git a/src/linkgraph/linkgraph_gui.h b/src/linkgraph/linkgraph_gui.h index 69ad612108..a57e573989 100644 --- a/src/linkgraph/linkgraph_gui.h +++ b/src/linkgraph/linkgraph_gui.h @@ -64,17 +64,17 @@ public: * @param company_mask Bitmask of companies to be shown. * @param scale Desired thickness of lines and size of station dots. */ - LinkGraphOverlay(const Window *w, uint wid, uint32 cargo_mask, uint32 company_mask, uint scale) : + LinkGraphOverlay(const Window *w, uint wid, CargoTypes cargo_mask, uint32 company_mask, uint scale) : window(w), widget_id(wid), cargo_mask(cargo_mask), company_mask(company_mask), scale(scale) {} void RebuildCache(); void Draw(const DrawPixelInfo *dpi); - void SetCargoMask(uint32 cargo_mask); + void SetCargoMask(CargoTypes cargo_mask); void SetCompanyMask(uint32 company_mask); /** Get a bitmask of the currently shown cargoes. */ - uint32 GetCargoMask() { return this->cargo_mask; } + CargoTypes GetCargoMask() { return this->cargo_mask; } /** Get a bitmask of the currently shown companies. */ uint32 GetCompanyMask() { return this->company_mask; } @@ -82,7 +82,7 @@ public: protected: const Window *window; ///< Window to be drawn into. const uint widget_id; ///< ID of Widget in Window to be drawn to. - uint32 cargo_mask; ///< Bitmask of cargos to be displayed. + CargoTypes cargo_mask; ///< Bitmask of cargos to be displayed. uint32 company_mask; ///< Bitmask of companies to be displayed. LinkList cached_links; ///< Cache for links to reduce recalculation. StationSupplyList cached_stations; ///< Cache for stations to be drawn. diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 7bdea7039c..a36ac23789 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -439,7 +439,7 @@ struct MainWindow : Window /* Cycle through the drawing modes */ this->viewport->map_type = ChangeRenderMode(this->viewport, wheel < 0); this->SetDirty(); - } else if (_settings_client.gui.scrollwheel_scrolling == 0) { + } else if (_settings_client.gui.scrollwheel_scrolling != 2) { ZoomInOrOutToCursorWindow(wheel < 0, this); } } diff --git a/src/misc/hashtable.hpp b/src/misc/hashtable.hpp index 1afe58cac7..1078f1861d 100644 --- a/src/misc/hashtable.hpp +++ b/src/misc/hashtable.hpp @@ -161,12 +161,10 @@ protected: /** static helper - return hash for the given key modulo number of slots */ inline static int CalcHash(const Tkey &key) { - int32 hash = key.CalcHash(); - if ((8 * Thash_bits) < 32) hash ^= hash >> (min(8 * Thash_bits, 31)); - if ((4 * Thash_bits) < 32) hash ^= hash >> (min(4 * Thash_bits, 31)); - if ((2 * Thash_bits) < 32) hash ^= hash >> (min(2 * Thash_bits, 31)); - if ((1 * Thash_bits) < 32) hash ^= hash >> (min(1 * Thash_bits, 31)); - hash &= (1 << Thash_bits) - 1; + uint32 hash = key.CalcHash(); + hash -= (hash >> 17); // hash * 131071 / 131072 + hash -= (hash >> 5); // * 31 / 32 + hash &= (1 << Thash_bits) - 1; // modulo slots return hash; } diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 605e24f7e1..b43f427010 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -317,8 +317,8 @@ struct GRFTempEngineData { Refittability refittability; ///< Did the newgrf set any refittability property? If not, default refittability will be applied. bool prop27_set; ///< Did the NewGRF set property 27 (misc flags)? uint8 rv_max_speed; ///< Temporary storage of RV prop 15, maximum speed in mph/0.8 - uint32 ctt_include_mask; ///< Cargo types always included in the refit mask. - uint32 ctt_exclude_mask; ///< Cargo types always excluded from the refit mask. + CargoTypes ctt_include_mask; ///< Cargo types always included in the refit mask. + CargoTypes ctt_exclude_mask; ///< Cargo types always excluded from the refit mask. /** * Update the summary refittability on setting a refittability property. @@ -948,11 +948,11 @@ static bool ReadSpriteLayout(ByteReader *buf, uint num_building_sprites, bool us } /** - * Translate the refit mask. + * Translate the refit mask. refit_mask is uint32 as it has not been mapped to CargoTypes. */ -static uint32 TranslateRefitMask(uint32 refit_mask) +static CargoTypes TranslateRefitMask(uint32 refit_mask) { - uint32 result = 0; + CargoTypes result = 0; uint8 bit; FOR_EACH_SET_BIT(bit, refit_mask) { CargoID cargo = GetCargoTranslation(bit, _cur.grffile, true); @@ -1315,7 +1315,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop uint8 count = buf->ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x2C && count != 0); if (prop == 0x2C) _gted[e->index].defaultcargo_grf = _cur.grffile; - uint32 &ctt = prop == 0x2C ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; + CargoTypes &ctt = prop == 0x2C ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { CargoID ctype = GetCargoTranslation(buf->ReadByte(), _cur.grffile); @@ -1503,7 +1503,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop uint8 count = buf->ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x24 && count != 0); if (prop == 0x24) _gted[e->index].defaultcargo_grf = _cur.grffile; - uint32 &ctt = prop == 0x24 ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; + CargoTypes &ctt = prop == 0x24 ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { CargoID ctype = GetCargoTranslation(buf->ReadByte(), _cur.grffile); @@ -1675,7 +1675,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop uint8 count = buf->ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x1E && count != 0); if (prop == 0x1E) _gted[e->index].defaultcargo_grf = _cur.grffile; - uint32 &ctt = prop == 0x1E ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; + CargoTypes &ctt = prop == 0x1E ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { CargoID ctype = GetCargoTranslation(buf->ReadByte(), _cur.grffile); @@ -1825,7 +1825,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int uint8 count = buf->ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x1D && count != 0); if (prop == 0x1D) _gted[e->index].defaultcargo_grf = _cur.grffile; - uint32 &ctt = prop == 0x1D ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; + CargoTypes &ctt = prop == 0x1D ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; ctt = 0; while (count--) { CargoID ctype = GetCargoTranslation(buf->ReadByte(), _cur.grffile); @@ -2041,9 +2041,10 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte break; case 0x12: // Cargo types for random triggers - statspec->cargo_triggers = buf->ReadDWord(); if (_cur.grffile->grf_version >= 7) { - statspec->cargo_triggers = TranslateRefitMask(statspec->cargo_triggers); + statspec->cargo_triggers = TranslateRefitMask(buf->ReadDWord()); + } else { + statspec->cargo_triggers = (CargoTypes)buf->ReadDWord(); } break; @@ -8319,9 +8320,9 @@ static void CalculateRefitMasks() /* Did the newgrf specify any refitting? If not, use defaults. */ if (_gted[engine].refittability != GRFTempEngineData::UNSET) { - uint32 mask = 0; - uint32 not_mask = 0; - uint32 xor_mask = ei->refit_mask; + CargoTypes mask = 0; + CargoTypes not_mask = 0; + CargoTypes xor_mask = ei->refit_mask; /* If the original masks set by the grf are zero, the vehicle shall only carry the default cargo. * Note: After applying the translations, the vehicle may end up carrying no defined cargo. It becomes unavailable in that case. */ @@ -8342,7 +8343,7 @@ static void CalculateRefitMasks() ei->refit_mask |= _gted[engine].ctt_include_mask; ei->refit_mask &= ~_gted[engine].ctt_exclude_mask; } else { - uint32 xor_mask = 0; + CargoTypes xor_mask = 0; /* Don't apply default refit mask to wagons nor engines with no capacity */ if (e->type != VEH_TRAIN || (e->u.rail.capacity != 0 && e->u.rail.railveh_type != RAILVEH_WAGON)) { diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index f553a8d659..2280e12b3d 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -59,7 +59,7 @@ static const GRFFile *GetHouseSpecGrf(HouseID house_id) */ HouseResolverObject::HouseResolverObject(HouseID house_id, TileIndex tile, Town *town, CallbackID callback, uint32 param1, uint32 param2, - bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers) + bool not_yet_constructed, uint8 initial_random_bits, CargoTypes watched_cargo_triggers) : ResolverObject(GetHouseSpecGrf(house_id), callback, param1, param2) { assert((tile != INVALID_TILE) == (town != NULL)); @@ -489,7 +489,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI } uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile, - bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers) + bool not_yet_constructed, uint8 initial_random_bits, CargoTypes watched_cargo_triggers) { HouseResolverObject object(house_id, tile, town, callback, param1, param2, not_yet_constructed, initial_random_bits, watched_cargo_triggers); @@ -610,13 +610,13 @@ void DrawNewHouseTileInGUI(int x, int y, HouseID house_id, bool ground) } /* Simple wrapper for GetHouseCallback to keep the animation unified. */ -uint16 GetSimpleHouseCallback(CallbackID callback, uint32 param1, uint32 param2, const HouseSpec *spec, Town *town, TileIndex tile, uint32 extra_data) +uint16 GetSimpleHouseCallback(CallbackID callback, uint32 param1, uint32 param2, const HouseSpec *spec, Town *town, TileIndex tile, CargoTypes extra_data) { return GetHouseCallback(callback, param1, param2, spec - HouseSpec::Get(0), town, tile, false, 0, extra_data); } /** Helper class for animation control. */ -struct HouseAnimationBase : public AnimationBase { +struct HouseAnimationBase : public AnimationBase { static const CallbackID cb_animation_speed = CBID_HOUSE_ANIMATION_SPEED; static const CallbackID cb_animation_next_frame = CBID_HOUSE_ANIMATION_NEXT_FRAME; @@ -791,7 +791,7 @@ void TriggerHouse(TileIndex t, HouseTrigger trigger) * @param trigger_cargoes Cargo types that triggered the callback. * @param random Random bits. */ -void DoWatchedCargoCallback(TileIndex tile, TileIndex origin, uint32 trigger_cargoes, uint16 random) +void DoWatchedCargoCallback(TileIndex tile, TileIndex origin, CargoTypes trigger_cargoes, uint16 random) { TileIndexDiffC diff = TileIndexToTileIndexDiffC(origin, tile); uint32 cb_info = random << 16 | (uint8)diff.y << 8 | (uint8)diff.x; @@ -804,7 +804,7 @@ void DoWatchedCargoCallback(TileIndex tile, TileIndex origin, uint32 trigger_car * @param trigger_cargoes Triggering cargo types. * @pre IsTileType(t, MP_HOUSE) */ -void WatchedCargoCallback(TileIndex tile, uint32 trigger_cargoes) +void WatchedCargoCallback(TileIndex tile, CargoTypes trigger_cargoes) { assert(IsTileType(tile, MP_HOUSE)); HouseID id = GetHouseType(tile); diff --git a/src/newgrf_house.h b/src/newgrf_house.h index 0d9d6c8a07..799f6ec39a 100644 --- a/src/newgrf_house.h +++ b/src/newgrf_house.h @@ -25,7 +25,7 @@ struct HouseScopeResolver : public ScopeResolver { Town *town; ///< Town of this house. bool not_yet_constructed; ///< True for construction check. uint16 initial_random_bits; ///< Random bits during construction checks. - uint32 watched_cargo_triggers; ///< Cargo types that triggered the watched cargo callback. + CargoTypes watched_cargo_triggers; ///< Cargo types that triggered the watched cargo callback. /** * Constructor of a house scope resolver. @@ -38,7 +38,7 @@ struct HouseScopeResolver : public ScopeResolver { * @param watched_cargo_triggers Cargo types that triggered the watched cargo callback. */ HouseScopeResolver(ResolverObject &ro, HouseID house_id, TileIndex tile, Town *town, - bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers) + bool not_yet_constructed, uint8 initial_random_bits, CargoTypes watched_cargo_triggers) : ScopeResolver(ro), house_id(house_id), tile(tile), town(town), not_yet_constructed(not_yet_constructed), initial_random_bits(initial_random_bits), watched_cargo_triggers(watched_cargo_triggers) { @@ -77,7 +77,7 @@ struct HouseResolverObject : public ResolverObject { HouseResolverObject(HouseID house_id, TileIndex tile = INVALID_TILE, Town *town = NULL, CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0, - bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0); + bool not_yet_constructed = false, uint8 initial_random_bits = 0, CargoTypes watched_cargo_triggers = 0); /* virtual */ ~HouseResolverObject(); @@ -121,7 +121,7 @@ void AnimateNewHouseTile(TileIndex tile); void AnimateNewHouseConstruction(TileIndex tile); uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town = NULL, TileIndex tile = INVALID_TILE, - bool not_yet_constructed = false, uint8 initial_random_bits = 0, uint32 watched_cargo_triggers = 0); + bool not_yet_constructed = false, uint8 initial_random_bits = 0, CargoTypes watched_cargo_triggers = 0); void WatchedCargoCallback(TileIndex tile, uint32 trigger_cargoes); bool HouseAllowsConstruction(HouseID house_id, TileIndex tile, Town *t, byte random_bits); diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index dee2755a3b..94c7dd6f2e 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -963,7 +963,7 @@ void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigg uint32 whole_reseed = 0; ETileArea area = ETileArea(st, tile, tas[trigger]); - uint32 empty_mask = 0; + CargoTypes empty_mask = 0; if (trigger == SRT_CARGO_TAKEN) { /* Create a bitmask of completely empty cargo types to be matched */ for (CargoID i = 0; i < NUM_CARGO; i++) { diff --git a/src/newgrf_station.h b/src/newgrf_station.h index fc4278571e..123330d0ad 100644 --- a/src/newgrf_station.h +++ b/src/newgrf_station.h @@ -153,7 +153,7 @@ struct StationSpec { */ uint16 cargo_threshold; - uint32 cargo_triggers; ///< Bitmask of cargo types which cause trigger re-randomizing + CargoTypes cargo_triggers; ///< Bitmask of cargo types which cause trigger re-randomizing byte callback_mask; ///< Bitmask of station callbacks that have to be called diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index df1dafa3ef..e40879cf9f 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -540,7 +540,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags) return cost; } -static void AddAcceptedCargo_Object(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted) +static void AddAcceptedCargo_Object(TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted) { if (!IsObjectType(tile, OBJECT_HQ)) return; diff --git a/src/roadveh.h b/src/roadveh.h index a2d26d5d04..6c90b5baf4 100644 --- a/src/roadveh.h +++ b/src/roadveh.h @@ -107,7 +107,7 @@ struct RoadVehicle FINAL : public GroundVehicle { friend struct GroundVehicle; // GroundVehicle needs to use the acceleration functions defined at RoadVehicle. void MarkDirty(); - void UpdateDeltaXY(Direction direction); + void UpdateDeltaXY(); ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; } bool IsPrimaryVehicle() const { return this->IsFrontEngine(); } void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const; diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 3d7b8db0c0..552bbed5a7 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -407,7 +407,7 @@ void RoadVehicle::MarkDirty() this->CargoChanged(); } -void RoadVehicle::UpdateDeltaXY(Direction direction) +void RoadVehicle::UpdateDeltaXY() { static const int8 _delta_xy_table[8][10] = { /* y_extent, x_extent, y_offs, x_offs, y_bb_offs, x_bb_offs, y_extent_shorten, x_extent_shorten, y_bb_offs_shorten, x_bb_offs_shorten */ @@ -422,9 +422,9 @@ void RoadVehicle::UpdateDeltaXY(Direction direction) }; int shorten = VEHICLE_LENGTH - this->gcache.cached_veh_length; - if (!IsDiagonalDirection(direction)) shorten >>= 1; + if (!IsDiagonalDirection(this->direction)) shorten >>= 1; - const int8 *bb = _delta_xy_table[direction]; + const int8 *bb = _delta_xy_table[this->direction]; this->x_bb_offs = bb[5] + bb[9] * shorten; this->y_bb_offs = bb[4] + bb[8] * shorten;; this->x_offs = bb[3]; diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index 3809681221..7749017181 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -261,7 +261,7 @@ static const SaveLoad _company_desc[] = { SLE_VAR(CompanyProperties, colour, SLE_UINT8), SLE_VAR(CompanyProperties, money_fraction, SLE_UINT8), - SLE_CONDVAR(CompanyProperties, avail_railtypes, SLE_VAR_I32 | SLE_FILE_I8, 0, 57), + SLE_CONDNULL(1, 0, 57), ///< avail_railtypes SLE_VAR(CompanyProperties, block_preview, SLE_UINT8), SLE_CONDNULL(2, 0, 93), ///< cargo_types diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index 8703b51953..976f18726e 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -944,7 +944,7 @@ static const OldChunks _company_chunk[] = { OCL_SVAR( OC_UINT8, Company, block_preview ), OCL_CNULL( OC_TTD, 1 ), // Old AI - OCL_SVAR( OC_TTD | OC_UINT8, Company, avail_railtypes ), + OCL_CNULL( OC_TTD, 1 ), // avail_railtypes OCL_SVAR( OC_TILE, Company, location_of_HQ ), OCL_SVAR( OC_TTD | OC_UINT8, Company, share_owners[0] ), OCL_SVAR( OC_TTD | OC_UINT8, Company, share_owners[1] ), diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp index 14674f0de0..e83a28831d 100644 --- a/src/saveload/town_sl.cpp +++ b/src/saveload/town_sl.cpp @@ -315,7 +315,7 @@ static void Load_TOWN() SlObject(&t->cargo_accepted, GetTileMatrixDesc()); if (t->cargo_accepted.area.w != 0) { uint arr_len = t->cargo_accepted.area.w / AcceptanceMatrix::GRID * t->cargo_accepted.area.h / AcceptanceMatrix::GRID; - t->cargo_accepted.data = MallocT(arr_len); + t->cargo_accepted.data = MallocT(arr_len); SlArray(t->cargo_accepted.data, arr_len, SLE_UINT32); /* Rebuild total cargo acceptance. */ diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index 68cdb2620f..2e293191f7 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -469,7 +469,7 @@ void AfterLoadVehicles(bool part_of_load) default: break; } - v->UpdateDeltaXY(v->direction); + v->UpdateDeltaXY(); v->coord.left = INVALID_COORD; v->UpdatePosition(); v->UpdateViewport(false); diff --git a/src/ship.h b/src/ship.h index 0d51987716..13983614b9 100644 --- a/src/ship.h +++ b/src/ship.h @@ -32,7 +32,7 @@ struct Ship FINAL : public SpecializedVehicle { virtual ~Ship() { this->PreDestructor(); } void MarkDirty(); - void UpdateDeltaXY(Direction direction); + void UpdateDeltaXY(); ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; } void PlayLeaveStationSound() const; bool IsPrimaryVehicle() const { return true; } diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 73cf915829..b75c030645 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -297,7 +297,7 @@ TileIndex Ship::GetOrderStationLocation(StationID station) } } -void Ship::UpdateDeltaXY(Direction direction) +void Ship::UpdateDeltaXY() { static const int8 _delta_xy_table[8][4] = { /* y_extent, x_extent, y_offs, x_offs */ @@ -311,7 +311,7 @@ void Ship::UpdateDeltaXY(Direction direction) {32, 6, -16, -3}, // NW }; - const int8 *bb = _delta_xy_table[direction]; + const int8 *bb = _delta_xy_table[this->direction]; this->x_offs = bb[3]; this->y_offs = bb[2]; this->x_extent = bb[1]; @@ -824,7 +824,7 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, const Engine *e, u v->y_pos = y; v->z_pos = GetSlopePixelZ(x, y); - v->UpdateDeltaXY(v->direction); + v->UpdateDeltaXY(); v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL; v->spritenum = svi->image_index; diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index ac7fb5961e..2853bf25fc 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1257,7 +1257,7 @@ void SmallMapWindow::SelectLegendItem(int click_pos, LegendAndColour *legend, in */ void SmallMapWindow::SetOverlayCargoMask() { - uint32 cargo_mask = 0; + CargoTypes cargo_mask = 0; for (int i = 0; i != _smallmap_cargo_count; ++i) { if (_legend_linkstats[i].show_on_map) SetBit(cargo_mask, _legend_linkstats[i].type); } @@ -1474,7 +1474,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt) /* virtual */ void SmallMapWindow::OnMouseWheel(int wheel) { - if (_settings_client.gui.scrollwheel_scrolling == 0) { + if (_settings_client.gui.scrollwheel_scrolling != 2) { const NWidgetBase *wid = this->GetWidget(WID_SM_MAP); int cursor_x = _cursor.pos.x - this->left - wid->pos_x; int cursor_y = _cursor.pos.y - this->top - wid->pos_y; diff --git a/src/sound/win32_s.h b/src/sound/win32_s.h index 77906c88a3..c6c8e8d149 100644 --- a/src/sound/win32_s.h +++ b/src/sound/win32_s.h @@ -26,7 +26,7 @@ public: /** Factory for the sound driver for Windows. */ class FSoundDriver_Win32 : public DriverFactoryBase { public: - FSoundDriver_Win32() : DriverFactoryBase(Driver::DT_SOUND, 10, "win32", "Win32 WaveOut Sound Driver") {} + FSoundDriver_Win32() : DriverFactoryBase(Driver::DT_SOUND, 9, "win32", "Win32 WaveOut Sound Driver") {} /* virtual */ Driver *CreateInstance() const { return new SoundDriver_Win32(); } }; diff --git a/src/sound/xaudio2_s.cpp b/src/sound/xaudio2_s.cpp new file mode 100644 index 0000000000..60311ced20 --- /dev/null +++ b/src/sound/xaudio2_s.cpp @@ -0,0 +1,273 @@ +/* $Id$ */ + +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ + +/** @file xaudio2_s.cpp XAudio2 sound driver. */ + +#ifdef WITH_XAUDIO2 + +#include "../stdafx.h" +#include "../openttd.h" +#include "../driver.h" +#include "../mixer.h" +#include "../debug.h" +#include "../core/alloc_func.hpp" +#include "../core/bitmath_func.hpp" +#include "../core/math_func.hpp" + +// Windows 8 SDK required for XAudio2 +#undef NTDDI_VERSION +#undef _WIN32_WINNT + +#define NTDDI_VERSION NTDDI_WIN8 +#define _WIN32_WINNT _WIN32_WINNT_WIN8 + +#include "xaudio2_s.h" + +#include +#include +#include +#include + +using Microsoft::WRL::ComPtr; + +#include "../os/windows/win32.h" +#include "../safeguards.h" + +// Definition of the "XAudio2Create" call used to initialise XAudio2 +typedef HRESULT(__stdcall *API_XAudio2Create)(_Outptr_ IXAudio2** ppXAudio2, UINT32 Flags, XAUDIO2_PROCESSOR XAudio2Processor); + +static FSoundDriver_XAudio2 iFSoundDriver_XAudio2; + +/** +* Implementation of the IXAudio2VoiceCallback interface. +* Provides buffered audio to XAudio2 from the OpenTTD mixer. +*/ +class StreamingVoiceContext : public IXAudio2VoiceCallback +{ +private: + int bufferLength; + char *buffer; + +public: + IXAudio2SourceVoice* SourceVoice; + + StreamingVoiceContext(int bufferLength) + { + this->bufferLength = bufferLength; + this->buffer = MallocT(bufferLength); + } + + virtual ~StreamingVoiceContext() + { + free(this->buffer); + } + + HRESULT SubmitBuffer() + { + // Ensure we do have a valid voice + if (this->SourceVoice == nullptr) + { + return E_FAIL; + } + + MxMixSamples(this->buffer, this->bufferLength / 4); + + XAUDIO2_BUFFER buf = { 0 }; + buf.AudioBytes = this->bufferLength; + buf.pAudioData = (const BYTE *) this->buffer; + + return SourceVoice->SubmitSourceBuffer(&buf); + } + + STDMETHOD_(void, OnVoiceProcessingPassStart)(UINT32) override + { + } + + STDMETHOD_(void, OnVoiceProcessingPassEnd)() override + { + } + + STDMETHOD_(void, OnStreamEnd)() override + { + } + + STDMETHOD_(void, OnBufferStart)(void*) override + { + } + + STDMETHOD_(void, OnBufferEnd)(void*) override + { + SubmitBuffer(); + } + + STDMETHOD_(void, OnLoopEnd)(void*) override + { + } + + STDMETHOD_(void, OnVoiceError)(void*, HRESULT) override + { + } +}; + +static HMODULE _xaudio_dll_handle; +static IXAudio2SourceVoice* _source_voice = nullptr; +static IXAudio2MasteringVoice* _mastering_voice = nullptr; +static ComPtr _xaudio2; +static StreamingVoiceContext* _voice_context = nullptr; + +/** +* Initialises the XAudio2 driver. +* +* @param parm Driver parameters. +* @return An error message if unsuccessful, or NULL otherwise. +* +*/ +const char *SoundDriver_XAudio2::Start(const char * const *parm) +{ + HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); + + if (FAILED(hr)) + { + DEBUG(driver, 0, "xaudio2_s: CoInitializeEx failed (%08x)", hr); + return "Failed to initialise COM"; + } + + _xaudio_dll_handle = LoadLibraryA(XAUDIO2_DLL_A); + + if (_xaudio_dll_handle == NULL) + { + CoUninitialize(); + + DEBUG(driver, 0, "xaudio2_s: Unable to load " XAUDIO2_DLL_A); + return "Failed to load XAudio2 DLL"; + } + + API_XAudio2Create xAudio2Create = (API_XAudio2Create) GetProcAddress(_xaudio_dll_handle, "XAudio2Create"); + + if (xAudio2Create == NULL) + { + FreeLibrary(_xaudio_dll_handle); + CoUninitialize(); + + DEBUG(driver, 0, "xaudio2_s: Unable to find XAudio2Create function in DLL"); + return "Failed to load XAudio2 DLL"; + } + + // Create the XAudio engine + UINT32 flags = 0; + hr = xAudio2Create(_xaudio2.GetAddressOf(), flags, XAUDIO2_DEFAULT_PROCESSOR); + + if (FAILED(hr)) + { + FreeLibrary(_xaudio_dll_handle); + CoUninitialize(); + + DEBUG(driver, 0, "xaudio2_s: XAudio2Create failed (%08x)", hr); + return "Failed to inititialise the XAudio2 engine"; + } + + // Create a mastering voice + hr = _xaudio2->CreateMasteringVoice(&_mastering_voice); + + if (FAILED(hr)) + { + _xaudio2.Reset(); + FreeLibrary(_xaudio_dll_handle); + CoUninitialize(); + + DEBUG(driver, 0, "xaudio2_s: CreateMasteringVoice failed (%08x)", hr); + return "Failed to create a mastering voice"; + } + + // Create a source voice to stream our audio + WAVEFORMATEX wfex; + + wfex.wFormatTag = WAVE_FORMAT_PCM; + wfex.nChannels = 2; + wfex.wBitsPerSample = 16; + wfex.nSamplesPerSec = GetDriverParamInt(parm, "hz", 44100); + wfex.nBlockAlign = (wfex.nChannels * wfex.wBitsPerSample) / 8; + wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign; + + // Limit buffer size to prevent overflows + int bufsize = GetDriverParamInt(parm, "bufsize", 8192); + bufsize = min(bufsize, UINT16_MAX); + + _voice_context = new StreamingVoiceContext(bufsize * 4); + + if (_voice_context == nullptr) + { + _mastering_voice->DestroyVoice(); + _xaudio2.Reset(); + FreeLibrary(_xaudio_dll_handle); + CoUninitialize(); + + return "Failed to create streaming voice context"; + } + + hr = _xaudio2->CreateSourceVoice(&_source_voice, &wfex, 0, 1.0f, _voice_context); + + if (FAILED(hr)) + { + _mastering_voice->DestroyVoice(); + _xaudio2.Reset(); + FreeLibrary(_xaudio_dll_handle); + CoUninitialize(); + + DEBUG(driver, 0, "xaudio2_s: CreateSourceVoice failed (%08x)", hr); + return "Failed to create a source voice"; + } + + _voice_context->SourceVoice = _source_voice; + hr = _source_voice->Start(0, 0); + + if (FAILED(hr)) + { + DEBUG(driver, 0, "xaudio2_s: _source_voice->Start failed (%08x)", hr); + + Stop(); + return "Failed to start the source voice"; + } + + MxInitialize(wfex.nSamplesPerSec); + + // Submit the first buffer + hr = _voice_context->SubmitBuffer(); + + if (FAILED(hr)) + { + DEBUG(driver, 0, "xaudio2_s: _voice_context->SubmitBuffer failed (%08x)", hr); + + Stop(); + return "Failed to submit the first audio buffer"; + } + + return NULL; +} + +/** +* Terminates the XAudio2 driver. +*/ +void SoundDriver_XAudio2::Stop() +{ + // Clean up XAudio2 + _source_voice->DestroyVoice(); + + delete _voice_context; + _voice_context = nullptr; + + _mastering_voice->DestroyVoice(); + + _xaudio2.Reset(); + + FreeLibrary(_xaudio_dll_handle); + CoUninitialize(); +} + +#endif diff --git a/src/sound/xaudio2_s.h b/src/sound/xaudio2_s.h new file mode 100644 index 0000000000..2385f49ee2 --- /dev/null +++ b/src/sound/xaudio2_s.h @@ -0,0 +1,33 @@ +/* $Id$ */ + +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ + +/** @file xaudio2_s.h Base for XAudio2 sound handling. */ + +#ifndef SOUND_XAUDIO2_H +#define SOUND_XAUDIO2_H + +#include "sound_driver.hpp" + +/** Implementation of the XAudio2 sound driver. */ +class SoundDriver_XAudio2 : public SoundDriver { +public: + /* virtual */ const char *Start(const char * const *param); + + /* virtual */ void Stop(); + /* virtual */ const char *GetName() const { return "xaudio2"; } +}; + +/** Factory for the XAudio2 sound driver. */ +class FSoundDriver_XAudio2 : public DriverFactoryBase { +public: + FSoundDriver_XAudio2() : DriverFactoryBase(Driver::DT_SOUND, 10, "xaudio2", "XAudio2 Sound Driver") {} + /* virtual */ Driver *CreateInstance() const { return new SoundDriver_XAudio2(); } +}; + +#endif /* SOUND_XAUDIO2_H */ diff --git a/src/station_base.h b/src/station_base.h index bd451475ba..9602e8b3bd 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -473,7 +473,7 @@ public: byte last_vehicle_type; std::vector loading_vehicles; GoodsEntry goods[NUM_CARGO]; ///< Goods at this station - uint32 always_accepted; ///< Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept cargo) + CargoTypes always_accepted; ///< Bitmask of always accepted cargo types (by houses, HQs, industry tiles when industry doesn't accept cargo) IndustryVector industries_near; ///< Cached list of industries near the station that can accept cargo, @see DeliverGoodsToIndustry() diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 58e4c50641..951806c0c3 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -442,12 +442,12 @@ void UpdateAllStationVirtCoords() * @param st Station to query * @return the expected mask */ -static uint GetAcceptanceMask(const Station *st) +static CargoTypes GetAcceptanceMask(const Station *st) { - uint mask = 0; + CargoTypes mask = 0; for (CargoID i = 0; i < NUM_CARGO; i++) { - if (HasBit(st->goods[i].status, GoodsEntry::GES_ACCEPTANCE)) mask |= 1 << i; + if (HasBit(st->goods[i].status, GoodsEntry::GES_ACCEPTANCE)) SetBit(mask, i); } return mask; } @@ -526,7 +526,7 @@ CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad) * @param rad Search radius in addition to given area * @param always_accepted bitmask of cargo accepted by houses and headquarters; can be NULL */ -CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, uint32 *always_accepted) +CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, CargoTypes *always_accepted) { CargoArray acceptance; if (always_accepted != NULL) *always_accepted = 0; @@ -564,7 +564,7 @@ CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, uint3 void UpdateStationAcceptance(Station *st, bool show_msg) { /* old accepted goods types */ - uint old_acc = GetAcceptanceMask(st); + CargoTypes old_acc = GetAcceptanceMask(st); /* And retrieve the acceptance. */ CargoArray acceptance; @@ -597,7 +597,7 @@ void UpdateStationAcceptance(Station *st, bool show_msg) } /* Only show a message in case the acceptance was actually changed. */ - uint new_acc = GetAcceptanceMask(st); + CargoTypes new_acc = GetAcceptanceMask(st); if (old_acc == new_acc) return; /* show a message to report that the acceptance was changed? */ @@ -3358,7 +3358,7 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i void TriggerWatchedCargoCallbacks(Station *st) { /* Collect cargoes accepted since the last big tick. */ - uint cargoes = 0; + CargoTypes cargoes = 0; for (CargoID cid = 0; cid < NUM_CARGO; cid++) { if (HasBit(st->goods[cid].status, GoodsEntry::GES_ACCEPTED_BIGTICK)) SetBit(cargoes, cid); } diff --git a/src/station_func.h b/src/station_func.h index f33dbd21fb..9748297f21 100644 --- a/src/station_func.h +++ b/src/station_func.h @@ -28,7 +28,7 @@ void ShowStationViewWindow(StationID station); void UpdateAllStationVirtCoords(); CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad); -CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, uint32 *always_accepted = NULL); +CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad, CargoTypes *always_accepted = NULL); void UpdateStationAcceptance(Station *st, bool show_msg); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 4d2cfb9dcd..0a3439c24b 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -58,7 +58,7 @@ int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies) { TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); - uint32 cargo_mask = 0; + CargoTypes cargo_mask = 0; if (_thd.drawstyle == HT_RECT && tile < MapSize()) { CargoArray cargoes; if (supplies) { @@ -158,8 +158,8 @@ protected: static Listing last_sorting; static byte facilities; // types of stations of interest static bool include_empty; // whether we should include stations without waiting cargo - static const uint32 cargo_filter_max; - static uint32 cargo_filter; // bitmap of cargo types to include + static const CargoTypes cargo_filter_max; + static CargoTypes cargo_filter; // bitmap of cargo types to include static const Station *last_station; /* Constants for sorting stations */ @@ -656,8 +656,8 @@ public: Listing CompanyStationsWindow::last_sorting = {false, 0}; byte CompanyStationsWindow::facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK; bool CompanyStationsWindow::include_empty = true; -const uint32 CompanyStationsWindow::cargo_filter_max = UINT32_MAX; -uint32 CompanyStationsWindow::cargo_filter = UINT32_MAX; +const CargoTypes CompanyStationsWindow::cargo_filter_max = ALL_CARGOTYPES; +CargoTypes CompanyStationsWindow::cargo_filter = ALL_CARGOTYPES; const Station *CompanyStationsWindow::last_station = NULL; /* Availible station sorting functions */ @@ -1805,7 +1805,7 @@ struct StationViewWindow : public Window { { const Station *st = Station::Get(this->window_number); - uint32 cargo_mask = 0; + CargoTypes cargo_mask = 0; for (CargoID i = 0; i < NUM_CARGO; i++) { if (HasBit(st->goods[i].status, GoodsEntry::GES_ACCEPTANCE)) SetBit(cargo_mask, i); } diff --git a/src/strings.cpp b/src/strings.cpp index a96fc7081c..79063439ef 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -1342,7 +1342,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg } case SCC_CARGO_LIST: { // {CARGO_LIST} - uint32 cmask = args->GetInt32(SCC_CARGO_LIST); + CargoTypes cmask = args->GetInt32(SCC_CARGO_LIST); bool first = true; const CargoSpec *cs; diff --git a/src/subsidy.cpp b/src/subsidy.cpp index 62b463ced3..bd2ed07be5 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -334,7 +334,7 @@ bool FindSubsidyTownCargoRoute() /* Select a random town. */ const Town *src_town = Town::GetRandom(); - uint32 town_cargo_produced = src_town->cargo_produced; + CargoTypes town_cargo_produced = src_town->cargo_produced; /* Passenger subsidies are not handled here. */ ClrBit(town_cargo_produced, CT_PASSENGERS); diff --git a/src/tile_cmd.h b/src/tile_cmd.h index 6b8d6c69f4..ce70232a02 100644 --- a/src/tile_cmd.h +++ b/src/tile_cmd.h @@ -81,7 +81,7 @@ typedef CommandCost ClearTileProc(TileIndex tile, DoCommandFlag flags); * @param acceptance Storage destination of the cargo acceptance in 1/8 * @param always_accepted Bitmask of always accepted cargo types */ -typedef void AddAcceptedCargoProc(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted); +typedef void AddAcceptedCargoProc(TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted); /** * Tile callback function signature for obtaining a tile description @@ -165,11 +165,11 @@ VehicleEnterTileStatus VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner); void GetTileDesc(TileIndex tile, TileDesc *td); -static inline void AddAcceptedCargo(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted) +static inline void AddAcceptedCargo(TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted) { AddAcceptedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_accepted_cargo_proc; if (proc == NULL) return; - uint32 dummy = 0; // use dummy bitmask so there don't need to be several 'always_accepted != NULL' checks + CargoTypes dummy = 0; // use dummy bitmask so there don't need to be several 'always_accepted != NULL' checks proc(tile, acceptance, always_accepted == NULL ? &dummy : always_accepted); } diff --git a/src/town.h b/src/town.h index e177f6aabd..7a411b391d 100644 --- a/src/town.h +++ b/src/town.h @@ -29,7 +29,7 @@ struct BuildingCounts { T class_count[HOUSE_CLASS_MAX]; }; -typedef TileMatrix AcceptanceMatrix; +typedef TileMatrix AcceptanceMatrix; static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY = 4; ///< value for custom town number in difficulty settings static const uint CUSTOM_TOWN_MAX_NUMBER = 5000; ///< this is the maximum number of towns a user can specify in customisation @@ -89,9 +89,9 @@ struct Town : TownPool::PoolItem<&_town_pool> { inline byte GetPercentTransported(CargoID cid) const { return this->supplied[cid].old_act * 256 / (this->supplied[cid].old_max + 1); } /* Cargo production and acceptance stats. */ - uint32 cargo_produced; ///< Bitmap of all cargoes produced by houses in this town. + CargoTypes cargo_produced; ///< Bitmap of all cargoes produced by houses in this town. AcceptanceMatrix cargo_accepted; ///< Bitmap of cargoes accepted by houses for each 4*4 map square of the town. - uint32 cargo_accepted_total; ///< NOSAVE: Bitmap of all cargoes accepted by houses in this town. + CargoTypes cargo_accepted_total; ///< NOSAVE: Bitmap of all cargoes accepted by houses in this town. uint16 time_until_rebuild; ///< time until we rebuild a house @@ -322,6 +322,6 @@ static inline uint16 TownTicksToGameTicks(uint16 ticks) { } -extern uint32 _town_cargoes_accepted; +extern CargoTypes _town_cargoes_accepted; #endif /* TOWN_H */ diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 4207852fc1..00e05625a9 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -54,7 +54,7 @@ #include "safeguards.h" TownID _new_town_id; -uint32 _town_cargoes_accepted; ///< Bitmap of all cargoes accepted by houses. +CargoTypes _town_cargoes_accepted; ///< Bitmap of all cargoes accepted by houses. /* Initialize the town-pool */ TownPool _town_pool("Town"); @@ -769,14 +769,14 @@ static void AddProducedCargo_Town(TileIndex tile, CargoArray &produced) AddProducedHouseCargo(GetHouseType(tile), tile, produced); } -static inline void AddAcceptedCargoSetMask(CargoID cargo, uint amount, CargoArray &acceptance, uint32 *always_accepted) +static inline void AddAcceptedCargoSetMask(CargoID cargo, uint amount, CargoArray &acceptance, CargoTypes *always_accepted) { if (cargo == CT_INVALID || amount == 0) return; acceptance[cargo] += amount; SetBit(*always_accepted, cargo); } -void AddAcceptedHouseCargo(HouseID house_id, TileIndex tile, CargoArray &acceptance, uint32 *always_accepted) +void AddAcceptedHouseCargo(HouseID house_id, TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted) { const HouseSpec *hs = HouseSpec::Get(house_id); Town *t = (tile == INVALID_TILE) ? NULL : Town::GetByTile(tile); @@ -820,7 +820,7 @@ void AddAcceptedHouseCargo(HouseID house_id, TileIndex tile, CargoArray &accepta } } -static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted) +static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted) { AddAcceptedHouseCargo(GetHouseType(tile), tile, acceptance, always_accepted); } @@ -880,7 +880,7 @@ void UpdateTownCargoTotal(Town *t) static void UpdateTownCargoes(Town *t, TileIndex start, bool update_total = true) { CargoArray accepted, produced; - uint32 dummy; + CargoTypes dummy; /* Gather acceptance for all houses in an area around the start tile. * The area is composed of the square the tile is in, extended one square in all @@ -894,7 +894,7 @@ static void UpdateTownCargoes(Town *t, TileIndex start, bool update_total = true } /* Create bitmap of produced and accepted cargoes. */ - uint32 acc = 0; + CargoTypes acc = 0; for (uint cid = 0; cid < NUM_CARGO; cid++) { if (accepted[cid] >= 8) SetBit(acc, cid); if (produced[cid] > 0) SetBit(t->cargo_produced, cid); diff --git a/src/train.h b/src/train.h index f7f85fb24a..439ec3c43c 100644 --- a/src/train.h +++ b/src/train.h @@ -130,7 +130,7 @@ struct Train FINAL : public GroundVehicle { friend struct GroundVehicle; // GroundVehicle needs to use the acceleration functions defined at Train. void MarkDirty(); - void UpdateDeltaXY(Direction direction); + void UpdateDeltaXY(); ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; } void PlayLeaveStationSound() const; bool IsPrimaryVehicle() const { return this->IsFrontEngine(); } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index f2b451fc66..17351dc0ef 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1673,7 +1673,7 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16 data, uint3 return cost; } -void Train::UpdateDeltaXY(Direction direction) +void Train::UpdateDeltaXY() { /* Set common defaults. */ this->x_offs = -1; @@ -1684,7 +1684,7 @@ void Train::UpdateDeltaXY(Direction direction) this->x_bb_offs = 0; this->y_bb_offs = 0; - if (!IsDiagonalDirection(direction)) { + if (!IsDiagonalDirection(this->direction)) { static const int _sign_table[] = { /* x, y */ @@ -1697,12 +1697,12 @@ void Train::UpdateDeltaXY(Direction direction) int half_shorten = (VEHICLE_LENGTH - this->gcache.cached_veh_length) / 2; /* For all straight directions, move the bound box to the centre of the vehicle, but keep the size. */ - this->x_offs -= half_shorten * _sign_table[direction]; - this->y_offs -= half_shorten * _sign_table[direction + 1]; + this->x_offs -= half_shorten * _sign_table[this->direction]; + this->y_offs -= half_shorten * _sign_table[this->direction + 1]; this->x_extent += this->x_bb_offs = half_shorten * _sign_table[direction]; this->y_extent += this->y_bb_offs = half_shorten * _sign_table[direction + 1]; } else { - switch (direction) { + switch (this->direction) { /* Shorten southern corner of the bounding box according the vehicle length * and center the bounding box on the vehicle. */ case DIR_NE: @@ -4171,7 +4171,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse) } /* update image of train, as well as delta XY */ - v->UpdateDeltaXY(v->direction); + v->UpdateDeltaXY(); v->x_pos = gp.x; v->y_pos = gp.y; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ca0a846d87..7f864b6495 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -260,7 +260,7 @@ bool Vehicle::NeedsServicing() const if (replace_when_old && !v->NeedsAutorenewing(c, false)) continue; /* Check refittability */ - uint32 available_cargo_types, union_mask; + CargoTypes available_cargo_types, union_mask; GetArticulatedRefitMasks(new_engine, true, &union_mask, &available_cargo_types); /* Is there anything to refit? */ if (union_mask != 0) { diff --git a/src/vehicle_base.h b/src/vehicle_base.h index f6e03e7c16..860c5a21c2 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -381,9 +381,8 @@ public: /** * Updates the x and y offsets and the size of the sprite used * for this vehicle. - * @param direction the direction the vehicle is facing */ - virtual void UpdateDeltaXY(Direction direction) {} + virtual void UpdateDeltaXY() {} /** * Determines the effective direction-specific vehicle movement speed. @@ -1233,7 +1232,7 @@ struct SpecializedVehicle : public Vehicle { /* Explicitly choose method to call to prevent vtable dereference - * it gives ~3% runtime improvements in games with many vehicles */ - if (update_delta) ((T *)this)->T::UpdateDeltaXY(this->direction); + if (update_delta) ((T *)this)->T::UpdateDeltaXY(); if (this->cur_image_valid_dir != this->direction) { _sprite_group_resolve_check_veh_check = true; _sprite_group_resolve_check_veh_type = EXPECTED_TYPE; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 4ed0d893d5..7098af503c 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -604,7 +604,7 @@ struct RefitWindow : public Window { do { if (v->type == VEH_TRAIN && !vehicles_to_refit.Contains(v->index)) continue; const Engine *e = v->GetEngine(); - uint32 cmask = e->info.refit_mask; + CargoTypes cmask = e->info.refit_mask; byte callback_mask = e->info.callback_mask; /* Skip this engine if it does not carry anything */ @@ -1270,9 +1270,9 @@ void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *pare uint ShowRefitOptionsList(int left, int right, int y, EngineID engine) { /* List of cargo types of this engine */ - uint32 cmask = GetUnionOfArticulatedRefitMasks(engine, false); + CargoTypes cmask = GetUnionOfArticulatedRefitMasks(engine, false); /* List of cargo types available in this climate */ - uint32 lmask = _cargo_mask; + CargoTypes lmask = _cargo_mask; /* Draw nothing if the engine is not refittable */ if (HasAtMostOneBit(cmask)) return y; diff --git a/src/video/cocoa/event.mm b/src/video/cocoa/event.mm index f4a7c2b421..30b6563b68 100644 --- a/src/video/cocoa/event.mm +++ b/src/video/cocoa/event.mm @@ -587,12 +587,12 @@ static bool QZ_PollEvent() while (_current_magnification >= 1.0f) { _current_magnification -= 1.0f; - _cursor.wheel++; + _cursor.wheel--; HandleMouseEvents(); } while (_current_magnification <= -1.0f) { _current_magnification += 1.0f; - _cursor.wheel--; + _cursor.wheel++; HandleMouseEvents(); } break; diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 3c5c2bb77a..7b273827f7 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -148,7 +148,7 @@ public: /* Cycle through the drawing modes */ this->viewport->map_type = ChangeRenderMode(this->viewport, wheel < 0); this->SetDirty(); - } else if (_settings_client.gui.scrollwheel_scrolling == 0) { + } else if (_settings_client.gui.scrollwheel_scrolling != 2) { ZoomInOrOutToCursorWindow(wheel < 0, this); } } diff --git a/src/window.cpp b/src/window.cpp index a0656cf205..b366fc2fd6 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2882,8 +2882,8 @@ static void MouseLoop(MouseClick click, int mousewheel) if (vp != NULL && (_game_mode == GM_MENU || _game_mode == GM_BOOTSTRAP || HasModalProgress())) return; if (mousewheel != 0) { - /* Send mousewheel event to window */ - w->OnMouseWheel(mousewheel); + /* Send mousewheel event to window, unless we're scrolling a viewport or the map */ + if (!scrollwheel_scrolling || (vp == NULL && w->window_class != WC_SMALLMAP)) w->OnMouseWheel(mousewheel); /* Dispatch a MouseWheelEvent for widgets if it is not a viewport */ if (vp == NULL) DispatchMouseWheelEvent(w, w->nested_root->GetWidgetFromPos(x - w->left, y - w->top), mousewheel);