Skip to content

Commit

Permalink
Merge branch 'openttd'
Browse files Browse the repository at this point in the history
  • Loading branch information
ldpl committed Apr 11, 2024
2 parents 27efad3 + 872e715 commit b5a0652
Show file tree
Hide file tree
Showing 42 changed files with 792 additions and 612 deletions.
13 changes: 13 additions & 0 deletions .changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
14.0-RC3 (2024-03-23)
------------------------------------------------------------------------
Fix #12347: Crash attempting to find catchment tiles of a station with no catchment area (#12348)
Fix #12319: Some SSE blitters were broken due to ODR violations (#12322)
Fix #12302: Allow empty train engines to use an invalid cargo type (#12325)
Fix #12305: Crash with large positive sprite x offset in engine preview window (#12313)
Fix #12166: Crash when opening tram road stop build window (#12168)
Fix #12092: Incorrect x-axis in cargo payment graph window (#12359)
Fix: Crash when attempting to join a company while not joined (#12353)
Change: Show unbunching action in timetable window (#12351)
Change: [Windows] Switch to Microsoft Azure code signing certificate (#12292)


14.0-RC2 (2024-03-16)
------------------------------------------------------------------------
Update: Bump bundled OpenTTD TTF fonts to version v0.6 (#12276)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- synchronize
branches:
- master
- release/**

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
Expand Down
43 changes: 19 additions & 24 deletions .github/workflows/release-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,6 @@ jobs:
with:
arch: ${{ matrix.host }}

- name: Import code signing certificate
shell: powershell
# If this is run on a fork, there may not be a certificate set up - continue in this case
continue-on-error: true
run: |
$tempFile = [System.IO.Path]::GetTempFileName()
$bytes = [System.Convert]::FromBase64String($env:WINDOWS_CERTIFICATE_P12)
[IO.File]::WriteAllBytes($tempFile, $bytes)
$pwd = ConvertTo-SecureString $env:WINDOWS_CERTIFICATE_PASSWORD -AsPlainText -Force
Import-PfxCertificate -FilePath $tempFile -CertStoreLocation Cert:\CurrentUser\My -Password $pwd
Remove-Item $tempFile
env:
WINDOWS_CERTIFICATE_P12: ${{ secrets.WINDOWS_CERTIFICATE_P12 }}
WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }}

- name: Build (with installer)
if: inputs.is_tag == 'true'
shell: bash
Expand All @@ -131,15 +116,19 @@ jobs:
-DHOST_BINARY_DIR=${GITHUB_WORKSPACE}/build-host \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DOPTION_SURVEY_KEY=${{ inputs.survey_key }} \
-DWINDOWS_CERTIFICATE_COMMON_NAME="${WINDOWS_CERTIFICATE_COMMON_NAME}" \
# EOF
echo "::endgroup::"
echo "::group::Build"
cmake --build . --target openttd
echo "::endgroup::"
env:
WINDOWS_CERTIFICATE_COMMON_NAME: ${{ secrets.WINDOWS_CERTIFICATE_COMMON_NAME }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_CODESIGN_ACCOUNT_NAME: ${{ secrets.AZURE_CODESIGN_ACCOUNT_NAME }}
AZURE_CODESIGN_ENDPOINT: ${{ secrets.AZURE_CODESIGN_ENDPOINT }}
AZURE_CODESIGN_PROFILE_NAME: ${{ secrets.AZURE_CODESIGN_PROFILE_NAME }}

- name: Build (without installer)
if: inputs.is_tag != 'true'
Expand All @@ -156,15 +145,19 @@ jobs:
-DHOST_BINARY_DIR=${GITHUB_WORKSPACE}/build-host \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DOPTION_SURVEY_KEY=${{ inputs.survey_key }} \
-DWINDOWS_CERTIFICATE_COMMON_NAME="${WINDOWS_CERTIFICATE_COMMON_NAME}" \
# EOF
echo "::endgroup::"
echo "::group::Build"
cmake --build . --target openttd
echo "::endgroup::"
env:
WINDOWS_CERTIFICATE_COMMON_NAME: ${{ secrets.WINDOWS_CERTIFICATE_COMMON_NAME }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_CODESIGN_ACCOUNT_NAME: ${{ secrets.AZURE_CODESIGN_ACCOUNT_NAME }}
AZURE_CODESIGN_ENDPOINT: ${{ secrets.AZURE_CODESIGN_ENDPOINT }}
AZURE_CODESIGN_PROFILE_NAME: ${{ secrets.AZURE_CODESIGN_PROFILE_NAME }}

- name: Create breakpad symbols
shell: bash
Expand Down Expand Up @@ -198,13 +191,15 @@ jobs:
- name: Sign installer
if: inputs.is_tag == 'true'
shell: bash
# If this is run on a fork, there may not be a certificate set up - continue in this case
continue-on-error: true
run: |
cd ${GITHUB_WORKSPACE}/build/bundles
../../os/windows/sign.bat *.exe "${WINDOWS_CERTIFICATE_COMMON_NAME}"
${GITHUB_WORKSPACE}/os/windows/sign.bat "${GITHUB_WORKSPACE}/build/bundles"
env:
WINDOWS_CERTIFICATE_COMMON_NAME: ${{ secrets.WINDOWS_CERTIFICATE_COMMON_NAME }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_CODESIGN_ACCOUNT_NAME: ${{ secrets.AZURE_CODESIGN_ACCOUNT_NAME }}
AZURE_CODESIGN_ENDPOINT: ${{ secrets.AZURE_CODESIGN_ENDPOINT }}
AZURE_CODESIGN_PROFILE_NAME: ${{ secrets.AZURE_CODESIGN_PROFILE_NAME }}

- name: Store bundles
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .ottdrev
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.0-RC2 20240316 0 694d6f2072fc608c7c45723124f695c8e7ffcdd2 1 0 2024
14.0-RC3 20240323 0 f5e49c01f6db0ef93bdf1e9c69fc16e60e19580a 1 0 2024
2 changes: 1 addition & 1 deletion .release_date
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-03-16 13:52 UTC
2024-03-23 14:52 UTC
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.0-RC2
14.0-RC3
13 changes: 13 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
14.0-RC3 (2024-03-23)
------------------------------------------------------------------------
Fix #12347: Crash attempting to find catchment tiles of a station with no catchment area (#12348)
Fix #12319: Some SSE blitters were broken due to ODR violations (#12322)
Fix #12302: Allow empty train engines to use an invalid cargo type (#12325)
Fix #12305: Crash with large positive sprite x offset in engine preview window (#12313)
Fix #12166: Crash when opening tram road stop build window (#12168)
Fix #12092: Incorrect x-axis in cargo payment graph window (#12359)
Fix: Crash when attempting to join a company while not joined (#12353)
Change: Show unbunching action in timetable window (#12351)
Change: [Windows] Switch to Microsoft Azure code signing certificate (#12292)


14.0-RC2 (2024-03-16)
------------------------------------------------------------------------
Update: Bump bundled OpenTTD TTF fonts to version v0.6 (#12276)
Expand Down
4 changes: 2 additions & 2 deletions cmake/InstallAndPackage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ elseif(WIN32)

set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-windows-${CPACK_SYSTEM_NAME}")

if(WINDOWS_CERTIFICATE_COMMON_NAME)
if(DEFINED ENV{AZURE_CODESIGN_PROFILE_NAME})
add_custom_command(TARGET openttd
POST_BUILD
COMMAND "${CMAKE_SOURCE_DIR}/os/windows/sign.bat" "$<TARGET_FILE:openttd>" "${WINDOWS_CERTIFICATE_COMMON_NAME}"
COMMAND "${CMAKE_SOURCE_DIR}/os/windows/sign.bat" "${BINARY_DESTINATION_DIR}"
)
endif()
elseif(UNIX)
Expand Down
5 changes: 4 additions & 1 deletion cmake/scripts/GenerateWidget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ foreach(ENUM IN LISTS ENUM_LINES)
endif()

# Check for enum match
if("${LINE}" MATCHES "^ *enum *${ENUM_PATTERN} *\{")
if("${LINE}" MATCHES "^ *enum *${ENUM_PATTERN}( *: *[^ ]*)? *\{")
# REGEX REPLACE does a REGEX MATCHALL and fails if an empty string is matched
string(REGEX MATCH "[^ ]*" RESULT "${LINE}")
string(REPLACE "${RESULT}" "" RM_INDENT "${LINE}")

string(REGEX MATCH " *: *[^ ]*" RESULT "${LINE}")
string(REPLACE "${RESULT}" "" LINE "${LINE}")

set(ACTIVE 1)
if(ACTIVE_COMMENT GREATER 0)
string(APPEND ${PLACE_HOLDER} "\n${COMMENT}")
Expand Down
18 changes: 1 addition & 17 deletions os/windows/sign.bat
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
@echo off
REM Signing script
REM Arguments: sign.bat exe_to_sign certificate_subject_name

REM This is a loose wrapper around the Microsoft signtool application (included in the Windows SDK).
REM See https://docs.microsoft.com/en-us/dotnet/framework/tools/signtool-exe for more details.

REM Path to signtool.exe
IF NOT DEFINED SIGNTOOL_PATH (SET SIGNTOOL_PATH=signtool)

REM URL of the timestamp server
IF NOT DEFINED SIGNTOOL_TIMESTAMP_URL (SET SIGNTOOL_TIMESTAMP_URL=http://timestamp.digicert.com)

REM Sign with SHA-1 for Windows 7 and below
"%SIGNTOOL_PATH%" sign -v -n %2 -t %SIGNTOOL_TIMESTAMP_URL% -fd sha1 %1

REM Sign with SHA-256 for Windows 8 and above
"%SIGNTOOL_PATH%" sign -v -n %2 -tr %SIGNTOOL_TIMESTAMP_URL% -fd sha256 -td sha256 -as %1
pwsh -File "%~dp0sign_azure.ps1" %1
40 changes: 40 additions & 0 deletions os/windows/sign_azure.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Signing script for Azure Code Signing
# Arguments: sign_azure.ps1 path_to_sign
#
# Environment variables must be set up before use:
#
# AZURE_TENANT_ID
# AZURE_CLIENT_ID
# AZURE_CLIENT_SECRET
# AZURE_CODESIGN_ACCOUNT_NAME
# AZURE_CODESIGN_ENDPOINT
# AZURE_CODESIGN_PROFILE_NAME

Param
(
# Files folder
[Parameter(Mandatory=$true, Position=0)]
$FilesFolder
)

if (!$Env:AZURE_CODESIGN_ENDPOINT -or !$Env:AZURE_CODESIGN_ACCOUNT_NAME -or !$Env:AZURE_CODESIGN_PROFILE_NAME -or
!$Env:AZURE_TENANT_ID -or !$Env:AZURE_CLIENT_ID -or !$Env:AZURE_CLIENT_SECRET)
{
"Code signing variables not found; most likely running in a fork. Skipping signing."
exit
}

Install-Module -Name AzureCodeSigning -Scope CurrentUser -RequiredVersion 0.3.0 -Force -Repository PSGallery

$params = @{}

$params["Endpoint"] = $Env:AZURE_CODESIGN_ENDPOINT
$params["CodeSigningAccountName"] = $Env:AZURE_CODESIGN_ACCOUNT_NAME
$params["CertificateProfileName"] = $Env:AZURE_CODESIGN_PROFILE_NAME
$params["FilesFolder"] = $FilesFolder
$params["FilesFolderFilter"] = "exe"
$params["FileDigest"] = "SHA256"
$params["TimestampRfc3161"] = "http://timestamp.acs.microsoft.com"
$params["TimestampDigest"] = "SHA256"

Invoke-AzureCodeSigning @params
27 changes: 17 additions & 10 deletions src/blitter/32bpp_sse_func.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@
#ifndef BLITTER_32BPP_SSE_FUNC_HPP
#define BLITTER_32BPP_SSE_FUNC_HPP

/* ATTENTION
* This file is compiled multiple times with different defines for SSE_VERSION and MARGIN_NORMAL_THRESHOLD.
* Be careful when declaring things with external linkage.
* Use internal linkage instead, i.e. "static".
*/
#define INTERNAL_LINKAGE static

#ifdef WITH_SSE

GNU_TARGET(SSE_TARGET)
inline void InsertFirstUint32(const uint32_t value, __m128i &into)
INTERNAL_LINKAGE inline void InsertFirstUint32(const uint32_t value, __m128i &into)
{
#if (SSE_VERSION >= 4)
into = _mm_insert_epi32(into, value, 0);
Expand All @@ -24,7 +31,7 @@ inline void InsertFirstUint32(const uint32_t value, __m128i &into)
}

GNU_TARGET(SSE_TARGET)
inline void InsertSecondUint32(const uint32_t value, __m128i &into)
INTERNAL_LINKAGE inline void InsertSecondUint32(const uint32_t value, __m128i &into)
{
#if (SSE_VERSION >= 4)
into = _mm_insert_epi32(into, value, 1);
Expand All @@ -35,7 +42,7 @@ inline void InsertSecondUint32(const uint32_t value, __m128i &into)
}

GNU_TARGET(SSE_TARGET)
inline void LoadUint64(const uint64_t value, __m128i &into)
INTERNAL_LINKAGE inline void LoadUint64(const uint64_t value, __m128i &into)
{
#ifdef POINTER_IS_64BIT
into = _mm_cvtsi64_si128(value);
Expand All @@ -50,7 +57,7 @@ inline void LoadUint64(const uint64_t value, __m128i &into)
}

GNU_TARGET(SSE_TARGET)
inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
INTERNAL_LINKAGE inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
{
#if (SSE_VERSION == 2)
from = _mm_and_si128(from, mask); // PAND, wipe high bytes to keep low bytes when packing
Expand All @@ -61,7 +68,7 @@ inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
}

GNU_TARGET(SSE_TARGET)
inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
INTERNAL_LINKAGE inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
{
#if (SSE_VERSION == 2)
__m128i alphaAB = _mm_shufflelo_epi16(from, 0x3F); // PSHUFLW, put alpha1 in front of each rgb1
Expand All @@ -73,7 +80,7 @@ inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
}

GNU_TARGET(SSE_TARGET)
inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
INTERNAL_LINKAGE inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
{
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8_t into uint16
__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
Expand All @@ -97,7 +104,7 @@ inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &dist
* rgb = rgb * ((256/4) * 4 - (alpha/4)) / ((256/4) * 4)
*/
GNU_TARGET(SSE_TARGET)
inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
INTERNAL_LINKAGE inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
{
__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128());
__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
Expand All @@ -111,7 +118,7 @@ inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribu

IGNORE_UNINITIALIZED_WARNING_START
GNU_TARGET(SSE_TARGET)
static Colour ReallyAdjustBrightness(Colour colour, uint8_t brightness)
INTERNAL_LINKAGE Colour ReallyAdjustBrightness(Colour colour, uint8_t brightness)
{
uint64_t c16 = colour.b | (uint64_t) colour.g << 16 | (uint64_t) colour.r << 32;
c16 *= brightness;
Expand Down Expand Up @@ -145,7 +152,7 @@ IGNORE_UNINITIALIZED_WARNING_STOP
/** ReallyAdjustBrightness() is not called that often.
* Inlining this function implies a far jump, which has a huge latency.
*/
inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
INTERNAL_LINKAGE inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
{
/* Shortcut for normal brightness. */
if (brightness == Blitter_32bppBase::DEFAULT_BRIGHTNESS) return colour;
Expand All @@ -154,7 +161,7 @@ inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
}

GNU_TARGET(SSE_TARGET)
inline __m128i AdjustBrightnessOfTwoPixels([[maybe_unused]] __m128i from, [[maybe_unused]] uint32_t brightness)
INTERNAL_LINKAGE inline __m128i AdjustBrightnessOfTwoPixels([[maybe_unused]] __m128i from, [[maybe_unused]] uint32_t brightness)
{
#if (SSE_VERSION < 3)
NOT_REACHED();
Expand Down
6 changes: 6 additions & 0 deletions src/blitter/32bpp_sse_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
#ifndef BLITTER_32BPP_SSE_TYPE_H
#define BLITTER_32BPP_SSE_TYPE_H

/* ATTENTION
* This file is compiled multiple times with different defines for SSE_VERSION.
* Be careful when declaring things with external linkage.
* Use internal linkage instead, i.e. "static".
*/

#ifdef WITH_SSE

#include "32bpp_simple.hpp"
Expand Down
8 changes: 7 additions & 1 deletion src/console_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,13 +922,19 @@ DEF_CONSOLE_CMD(ConJoinCompany)

CompanyID company_id = (CompanyID)(atoi(argv[1]) <= MAX_COMPANIES ? atoi(argv[1]) - 1 : atoi(argv[1]));

const NetworkClientInfo *info = NetworkClientInfo::GetByClientID(_network_own_client_id);
if (info == nullptr) {
IConsolePrint(CC_ERROR, "You have not joined the game yet!");
return true;
}

/* Check we have a valid company id! */
if (!Company::IsValidID(company_id) && company_id != COMPANY_SPECTATOR) {
IConsolePrint(CC_ERROR, "Company does not exist. Company-id must be between 1 and {}.", MAX_COMPANIES);
return true;
}

if (NetworkClientInfo::GetByClientID(_network_own_client_id)->client_playas == company_id) {
if (info->client_playas == company_id) {
IConsolePrint(CC_ERROR, "You are already there!");
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct EnginePreviewWindow : Window {
}
this->vehicle_space = std::max<int>(ScaleSpriteTrad(40), y - y_offs);

size->width = std::max(size->width, x - x_offs);
size->width = std::max(size->width, x + std::abs(x_offs));
SetDParam(0, GetEngineCategoryName(engine));
size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WidgetDimensions::scaled.vsep_wide + GetCharacterHeight(FS_NORMAL) + this->vehicle_space;
SetDParam(0, engine);
Expand Down
4 changes: 2 additions & 2 deletions src/graph_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ struct BaseGraphWindow : Window {
static const int GRAPH_ZERO_LINE_COLOUR = GREY_SCALE(8);
static const int GRAPH_YEAR_LINE_COLOUR = GREY_SCALE(5);
static const int GRAPH_NUM_MONTHS = 24; ///< Number of months displayed in the graph.
static const int PAYMENT_GRAPH_X_STEP_DAYS = 20; ///< X-axis step label for cargo payment rates "Days in transit".
static const int PAYMENT_GRAPH_X_STEP_SECONDS = 10; ///< X-axis step label for cargo payment rates "Seconds in transit".
static const int PAYMENT_GRAPH_X_STEP_DAYS = 10; ///< X-axis step label for cargo payment rates "Days in transit".
static const int PAYMENT_GRAPH_X_STEP_SECONDS = 20; ///< X-axis step label for cargo payment rates "Seconds in transit".
static const int ECONOMY_QUARTER_MINUTES = 3; ///< Minutes per economic quarter.

static const TextColour GRAPH_AXIS_LABEL_COLOUR = TC_BLACK; ///< colour of the graph axis label.
Expand Down
Loading

0 comments on commit b5a0652

Please sign in to comment.