Merge remote-tracking branch 'upstream/1.11' into 1.11

This commit is contained in:
dP
2021-04-02 20:03:24 +03:00
8 changed files with 54 additions and 37 deletions

View File

@@ -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 \

View File

@@ -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

View File

@@ -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

View File

@@ -26,7 +26,6 @@ add_subdirectory(table)
add_subdirectory(video)
add_subdirectory(widgets)
add_files(
viewport_sprite_sorter_sse4.cpp
CONDITION SSE_FOUND

View File

@@ -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
*/

View File

@@ -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();

View File

@@ -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

View File

@@ -2540,11 +2540,10 @@ std::optional<SavePreset> 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;