diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 3b46ec37c6..1aa7e17ccb 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -75,6 +75,9 @@ jobs: - compiler: gcc cxxcompiler: g++ libsdl: libsdl1.2-dev + - compiler: gcc + cxxcompiler: g++ + extra-cmake-parameters: -DOPTION_DEDICATED=ON runs-on: ubuntu-20.04 env: @@ -97,7 +100,6 @@ jobs: libfontconfig-dev \ libicu-dev \ liblzma-dev \ - libzstd-dev \ liblzo2-dev \ ${{ matrix.libsdl }} \ zlib1g-dev \ @@ -130,7 +132,7 @@ jobs: cd build echo "::group::CMake" - cmake .. + cmake .. ${{ matrix.extra-cmake-parameters }} echo "::endgroup::" echo "::group::Build" @@ -170,7 +172,7 @@ jobs: uses: actions/cache@v2 with: path: /usr/local/share/vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified + key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-0 # Increase the number whenever dependencies are modified restore-keys: | ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} @@ -178,7 +180,6 @@ jobs: run: | vcpkg install --triplet=${{ matrix.arch }}-osx \ liblzma \ - zstd \ libpng \ lzo \ zlib \ @@ -253,7 +254,7 @@ jobs: uses: actions/cache@v2 with: path: vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified + key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-0 # Increase the number whenever dependencies are modified restore-keys: | ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} @@ -262,7 +263,6 @@ jobs: run: | vcpkg install --triplet=${{ matrix.arch }}-windows-static \ liblzma \ - zstd \ libpng \ lzo \ zlib \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 19a0dc54b6..84e8c17d98 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -297,7 +297,6 @@ jobs: SDL2-devel \ wget \ xz-devel \ - libzstd-devel \ zlib-devel \ # EOF echo "::endgroup::" @@ -413,7 +412,6 @@ jobs: libfluidsynth-dev \ libicu-dev \ liblzma-dev \ - libzstd-dev \ liblzo2-dev \ libsdl2-dev \ lsb-release \ @@ -498,7 +496,7 @@ jobs: uses: actions/cache@v2 with: path: /usr/local/share/vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-release-1 # Increase the number whenever dependencies are modified + key: ${{ steps.key.outputs.image }}-vcpkg-release-0 # Increase the number whenever dependencies are modified restore-keys: | ${{ steps.key.outputs.image }}-vcpkg-release ${{ steps.key.outputs.image }}-vcpkg-x64 @@ -508,8 +506,6 @@ jobs: vcpkg install \ liblzma:x64-osx \ liblzma:arm64-osx \ - zstd:x64-osx \ - zstd:arm64-osx \ libpng:x64-osx \ libpng:arm64-osx \ lzo:x64-osx \ @@ -703,7 +699,7 @@ jobs: uses: actions/cache@v2 with: path: vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified + key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-0 # Increase the number whenever dependencies are modified restore-keys: | ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} @@ -712,7 +708,6 @@ jobs: run: | vcpkg install --triplet=${{ matrix.arch }}-windows-static \ liblzma \ - zstd \ libpng \ lzo \ zlib \ @@ -869,7 +864,7 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_REGION }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} - name: Trigger 'New OpenTTD release' uses: peter-evans/repository-dispatch@v1 diff --git a/CMakeLists.txt b/CMakeLists.txt index d4e04c9484..15dd94df58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,28 +120,31 @@ find_package(LZO) find_package(ZSTD 1.4) find_package(PNG) -if(NOT WIN32) - find_package(Allegro) - if(NOT APPLE) - find_package(Freetype) - find_package(SDL2) - if(NOT SDL2_FOUND) - find_package(SDL) +if(NOT OPTION_DEDICATED) + if(NOT WIN32) + find_package(Allegro) + if(NOT APPLE) + find_package(Freetype) + find_package(SDL2) + if(NOT SDL2_FOUND) + find_package(SDL) + endif() + find_package(Fluidsynth) + find_package(Fontconfig) + find_package(ICU OPTIONAL_COMPONENTS i18n lx) endif() - find_package(Fluidsynth) - find_package(Fontconfig) - find_package(ICU OPTIONAL_COMPONENTS i18n lx) - else() - find_package(Iconv) - - find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox) - find_library(AUDIOUNIT_LIBRARY AudioUnit) - find_library(COCOA_LIBRARY Cocoa) - find_library(QUARTZCORE_LIBRARY QuartzCore) endif() endif() +if(APPLE) + find_package(Iconv) -if(NOT EMSCRIPTEN) + find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox) + find_library(AUDIOUNIT_LIBRARY AudioUnit) + find_library(COCOA_LIBRARY Cocoa) + find_library(QUARTZCORE_LIBRARY QuartzCore) +endif() + +if(NOT EMSCRIPTEN AND NOT OPTION_DEDICATED) find_package(OpenGL COMPONENTS OpenGL) endif() @@ -219,7 +222,7 @@ if(MSVC) endif() add_subdirectory(${CMAKE_SOURCE_DIR}/src) -add_subdirectory(${CMAKE_SOURCE_DIR}/media/baseset) +add_subdirectory(${CMAKE_SOURCE_DIR}/media) add_dependencies(openttd find_version) @@ -227,6 +230,7 @@ add_dependencies(openttd target_link_libraries(openttd openttd::languages openttd::settings + openttd::media openttd::basesets openttd::script_api Threads::Threads diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0856d4de0f..82fd721afc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,7 +26,6 @@ add_subdirectory(table) add_subdirectory(video) add_subdirectory(widgets) - add_files( viewport_sprite_sorter_sse4.cpp CONDITION SSE_FOUND diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp index 94ffcc5584..a7931e4c55 100644 --- a/src/network/core/packet.cpp +++ b/src/network/core/packet.cpp @@ -180,6 +180,21 @@ bool Packet::CanReadFromPacket(uint bytes_to_read) return true; } +/* CityMania code begin */ +bool Packet::CMCheckRead(uint bytes_to_read) +{ + /* Don't allow reading from a quit client/client who send bad data */ + if (this->cs->HasClientQuit()) return false; + + /* Check if variable is within packet-size */ + if (this->pos + bytes_to_read > this->size) { + return false; + } + + return true; +} +/* CityMania code end */ + /** * Reads the packet size from the raw packet and stores it in the packet->size */ diff --git a/src/network/core/packet.h b/src/network/core/packet.h index c9be4eeb53..ec7557260b 100644 --- a/src/network/core/packet.h +++ b/src/network/core/packet.h @@ -75,6 +75,7 @@ public: void PrepareToRead(); bool CanReadFromPacket (uint bytes_to_read); + bool CMCheckRead (uint bytes_to_read); // CityMaina needs check that doesn't close connections bool Recv_bool (); uint8 Recv_uint8 (); uint16 Recv_uint16(); diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 467366e21a..8e0cf40eda 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -925,7 +925,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p) p->Recv_string(name, sizeof(name)); playas = (Owner)p->Recv_uint8(); client_lang = (NetworkLanguage)p->Recv_uint8(); - uint8 savegame_formats = p->CanReadFromPacket(1) ? p->Recv_uint8() : 23u /* assume non-modded has everything but zstd */; + uint8 savegame_formats = p->CMCheckRead(1) ? p->Recv_uint8() : 23u /* assume non-modded has everything but zstd */; if (this->HasClientQuit()) return NETWORK_RECV_STATUS_CONN_LOST; @@ -934,6 +934,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p) if (!preset) return this->SendError(NETWORK_ERROR_NOT_EXPECTED); this->cm_preset = *preset; + DEBUG(sl, 2, "Using saveload preset '%s:%d' for client %d (mask %d)", this->cm_preset.format->name, (int)this->cm_preset.compression_level, (int)this->client_id, (int)savegame_formats); + /* join another company does not affect these values */ switch (playas) { case COMPANY_NEW_COMPANY: // New company diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 9d050679fd..0dd8ce7b1f 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -2540,11 +2540,10 @@ std::optional FindCompatibleSavePreset(const std::string &server_for */ uint8 GetAvailableLoadFormats() { - return 3; uint8 res = 0; for(auto &slf : _saveload_formats) { if (slf.init_load != nullptr) { - res &= (1 << slf.id); + res |= (1 << slf.id); } } return res; @@ -2890,6 +2889,8 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, err_str); } + DEBUG(sl, 2, "Using saveload format '%s'", fmt->name); + _sl.lf = fmt->init_load(_sl.lf); _sl.reader = new ReadBuffer(_sl.lf); _next_offs = 0;