Merge commit '13.0-RC1~2'

This commit is contained in:
2023-02-25 04:49:57 +00:00
603 changed files with 26913 additions and 18390 deletions

View File

@@ -1,4 +1,4 @@
FROM emscripten/emsdk:2.0.34
FROM emscripten/emsdk:3.1.28
COPY emsdk-liblzma.patch /
RUN cd /emsdk/upstream/emscripten && patch -p1 < /emsdk-liblzma.patch

View File

@@ -1,23 +1,38 @@
## How to build with Emscripten
Building with Emscripten works with emsdk 3.0.0 and above.
You will also need libharfbuzz-dev and libicu-dev installed on your host OS.
Please use docker with the supplied `Dockerfile` to build for emscripten.
It takes care of a few things:
- Use a version of emscripten we know works
- Patch in LibLZMA support (as this is not supported by upstream)
First, build the docker image by navigating in the folder this `README.md` is in, and executing:
```
sudo apt-get install autoconf automake libtool gperf libharfbuzz-dev libicu-dev libfreetype-dev
./emscripten-build.sh
docker build -t emsdk-lzma .
```
And now you have in your build folder files like "openttd.html".
Next, navigate back to the root folder of this project.
To run it locally, you would have to start a local webserver, like:
Now we build the host tools first:
```
mkdir build-host
docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build-host emsdk-lzma cmake .. -DOPTION_TOOLS_ONLY=ON
docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build-host emsdk-lzma make -j$(nproc) tools
```
Finally, we build the actual game:
```
mkdir build
docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build emsdk-lzma emcmake cmake .. -DHOST_BINARY_DIR=../build-host -DCMAKE_BUILD_TYPE=Release -DOPTION_USE_ASSERTS=OFF
docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build emsdk-lzma emmake make -j$(nproc)
```
In the `build` folder you will now see `openttd.html`.
To run it locally, you would have to start a local webserver; something like:
```
cd build
python3 -m http.server
````
Now you can play the game via http://127.0.0.1:8000/openttd.html .
You can now play the game via http://127.0.0.1:8000/openttd.html .

View File

@@ -32,6 +32,6 @@
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>LSMinimumSystemVersion</key>
<string>10.14.0</string>
<string>10.13.0</string>
</dict>
</plist>

View File

@@ -10,6 +10,7 @@
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2,PerMonitor</dpiAwareness>
</windowsSettings>
</application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">

View File

@@ -0,0 +1,2 @@
@echo off
powershell -File "%~dp0generate-assets.ps1"

View File

@@ -0,0 +1,48 @@
function ResizeImage() {
param([String]$sourcePath, [Int]$targetWidth, [Int]$targetHeight, [String]$targetPath)
Add-Type -AssemblyName "System.Drawing"
$img = [System.Drawing.Image]::FromFile($sourcePath)
$ratioX = $targetWidth / $img.Width;
$ratioY = $targetHeight / $img.Height;
$ratio = $ratioY
if ($ratioX -le $ratioY) {
$ratio = $ratioX
}
$newWidth = [int] ($img.Width * $ratio)
$newHeight = [int] ($img.Height * $ratio)
$resizedImage = New-Object System.Drawing.Bitmap($targetWidth, $targetHeight)
$graph = [System.Drawing.Graphics]::FromImage($resizedImage)
$graph.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
$graph.Clear([System.Drawing.Color]::Transparent)
$graph.DrawImage($img, $targetWidth / 2 - $newWidth / 2, $targetHeight / 2 - $newHeight / 2, $newWidth, $newHeight)
$resizedImage.Save($targetPath)
$resizedImage.Dispose()
$img.Dispose()
}
$logoPath = "..\..\..\media\openttd.2048.png"
# Create the main image assets required for the Windows Store
New-Item -Path "." -Name "assets" -ItemType "directory" -Force
ResizeImage $logoPath 1240 1240 "assets\LargeTile.png"
ResizeImage $logoPath 284 284 "assets\SmallTile.png"
ResizeImage $logoPath 2480 1200 "assets\SplashScreen.png"
ResizeImage $logoPath 176 176 "assets\Square44x44Logo.png"
Copy-Item "assets\Square44x44Logo.png" -Destination "assets\Square44x44Logo.targetsize-44_altform-unplated.png"
ResizeImage $logoPath 600 600 "assets\Square150x150Logo.png"
Copy-Item "assets\Square150x150Logo.png" -Destination "assets\Square150x150Logo.targetsize-150_altform-unplated.png"
ResizeImage $logoPath 200 200 "assets\StoreLogo.png"
ResizeImage $logoPath 1240 600 "assets\Wide310x150Logo.png"
# Copy the logo for the store for the common package
New-Item -Path "." -Name "assets-common" -ItemType "directory" -Force
Copy-Item "assets\StoreLogo.png" -Destination "assets-common\StoreLogo.png"

View File

@@ -0,0 +1,2 @@
@echo off
powershell -File "%~dp0generate-key.ps1" %1 %2 %3

View File

@@ -0,0 +1,21 @@
[CmdletBinding()]
[Alias()]
Param
(
# Publisher ("CN=xyz")
[Parameter(Mandatory=$true, Position=0)]
$Publisher,
# Password
[Parameter(Mandatory=$true, Position=1)]
$PasswordParam,
# Filename
[Parameter(Mandatory=$true, Position=2)]
$OutputFilename
)
$cert = New-SelfSignedCertificate -Type Custom -Subject $Publisher -KeyUsage DigitalSignature -FriendlyName "OpenTTD signing certificate" -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")
$password = ConvertTo-SecureString -String $PasswordParam -Force -AsPlainText
Export-PfxCertificate -cert "Cert:\CurrentUser\My\$($cert.Thumbprint)" -FilePath $OutputFilename -Password $password

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap6="http://schemas.microsoft.com/appx/manifest/uap/windows10/6" IgnorableNamespaces="uap uap6">
<Identity Name="$IDENTITY_NAME$" Publisher="$PUBLISHER$" Version="$VERSION$" ResourceId="OpenTTD-common" />
<Properties>
<uap6:AllowExecution>false</uap6:AllowExecution>
<DisplayName>OpenTTD (official)</DisplayName>
<PublisherDisplayName>OpenTTD Developers</PublisherDisplayName>
<Logo>Assets\StoreLogoCommon.png</Logo>
</Properties>
<Resources>
<Resource Language="en-gb" />
<Resource Language="en-us" />
<Resource Language="en-au" />
<Resource Language="af-za" />
<Resource Language="ar-eg" />
<Resource Language="eu-es" />
<Resource Language="be-by" />
<Resource Language="pt-br" />
<Resource Language="bg-bg" />
<Resource Language="ca-es" />
<Resource Language="hr-hr" />
<Resource Language="cs-cz" />
<Resource Language="da-dk" />
<Resource Language="nl-nl" />
<Resource Language="et-ee" />
<Resource Language="fo-fo" />
<Resource Language="fr-fr" />
<Resource Language="gd-gb" />
<Resource Language="gl-es" />
<Resource Language="de-de" />
<Resource Language="el-gr" />
<Resource Language="he-il" />
<Resource Language="hu-hu" />
<Resource Language="is-is" />
<Resource Language="id-id" />
<Resource Language="ga-ie" />
<Resource Language="it-it" />
<Resource Language="ja-jp" />
<Resource Language="ko-kr" />
<Resource Language="lv-lv" />
<Resource Language="lt-lt" />
<Resource Language="lb-lu" />
<Resource Language="ms-my" />
<Resource Language="nb-no" />
<Resource Language="no-no" />
<Resource Language="pl-pl" />
<Resource Language="pt-pt" />
<Resource Language="ro-ro" />
<Resource Language="ru-ru" />
<Resource Language="sr-latn-rs" />
<Resource Language="zh-cn" />
<Resource Language="sk-sk" />
<Resource Language="sl-si" />
<Resource Language="es-es" />
<Resource Language="es-mx" />
<Resource Language="sv-se" />
<Resource Language="ta-in" />
<Resource Language="th-th" />
<Resource Language="zh-tw" />
<Resource Language="tr-tr" />
<Resource Language="uk-ua" />
<Resource Language="vi-vn" />
<Resource Language="cy-gb" />
</Resources>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17134.0" MaxVersionTested="10.0.18363.0" />
</Dependencies>
</Package>

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap">
<Identity Name="$IDENTITY_NAME$" Publisher="$PUBLISHER$" Version="$VERSION$" ProcessorArchitecture="$ARCHITECTURE$" />
<Properties>
<DisplayName>OpenTTD (official)</DisplayName>
<PublisherDisplayName>OpenTTD Developers</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17134.0" MaxVersionTested="10.0.18363.0" />
</Dependencies>
<Resources>
<Resource Language="en-gb" />
<Resource Language="en-us" />
<Resource Language="en-au" />
<Resource Language="af-za" />
<Resource Language="ar-eg" />
<Resource Language="eu-es" />
<Resource Language="be-by" />
<Resource Language="pt-br" />
<Resource Language="bg-bg" />
<Resource Language="ca-es" />
<Resource Language="hr-hr" />
<Resource Language="cs-cz" />
<Resource Language="da-dk" />
<Resource Language="nl-nl" />
<!-- <Resource Language="eo-eo" />-->
<Resource Language="et-ee" />
<Resource Language="fo-fo" />
<!-- <Resource Language="fi-fi" />-->
<Resource Language="fr-fr" />
<Resource Language="gd-gb" />
<Resource Language="gl-es" />
<Resource Language="de-de" />
<Resource Language="el-gr" />
<Resource Language="he-il" />
<Resource Language="hu-hu" />
<Resource Language="is-is" />
<Resource Language="id-id" />
<Resource Language="ga-ie" />
<Resource Language="it-it" />
<Resource Language="ja-jp" />
<Resource Language="ko-kr" />
<!-- <Resource Language="la-va" />-->
<Resource Language="lv-lv" />
<Resource Language="lt-lt" />
<Resource Language="lb-lu" />
<Resource Language="ms-my" />
<Resource Language="nb-no" />
<Resource Language="no-no" />
<Resource Language="pl-pl" />
<Resource Language="pt-pt" />
<Resource Language="ro-ro" />
<Resource Language="ru-ru" />
<Resource Language="sr-latn-rs" />
<Resource Language="zh-cn" />
<Resource Language="sk-sk" />
<Resource Language="sl-si" />
<Resource Language="es-es" />
<Resource Language="es-mx" />
<Resource Language="sv-se" />
<Resource Language="ta-in" />
<Resource Language="th-th" />
<Resource Language="zh-tw" />
<Resource Language="tr-tr" />
<Resource Language="uk-ua" />
<Resource Language="vi-vn" />
<Resource Language="cy-gb" />
</Resources>
<Applications>
<Application Id="OpenTTD" Executable="openttd.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="OpenTTD (official)" Description="OpenTTD is an open source simulation game based upon Transport Tycoon Deluxe." BackgroundColor="transparent" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square310x310Logo="Assets\LargeTile.png" Square71x71Logo="Assets\SmallTile.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClientServer" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

View File

@@ -0,0 +1,35 @@
<PackagingLayout xmlns="http://schemas.microsoft.com/appx/makeappx/2017">
<!-- Main game -->
<PackageFamily ID="OpenTTD" FlatBundle="false" ManifestPath="manifests\Package.appxmanifest" ResourceManager="false">
<!-- x86 code package-->
<Package ID="OpenTTD-x86" ProcessorArchitecture="x86" ManifestPath="manifests\Package-x86.appxmanifest">
<Files>
<File DestinationPath="**" SourcePath="x86-binaries\**"/>
<File DestinationPath="Assets\**" SourcePath="Assets\**"/>
</Files>
</Package>
<!-- x64 code package-->
<Package ID="OpenTTD-x64" ProcessorArchitecture="x64" ManifestPath="manifests\Package-x64.appxmanifest">
<Files>
<File DestinationPath="**" SourcePath="x64-binaries\**"/>
<File DestinationPath="Assets\**" SourcePath="Assets\**"/>
</Files>
</Package>
<!-- ARM64 code package-->
<Package ID="OpenTTD-ARM64" ProcessorArchitecture="arm64" ManifestPath="manifests\Package-ARM64.appxmanifest">
<Files>
<File DestinationPath="**" SourcePath="ARM64-binaries\**"/>
<File DestinationPath="Assets\**" SourcePath="Assets\**"/>
</Files>
</Package>
<!-- Common asset package-->
<AssetPackage ID="OpenTTD-common" AllowExecution="false" ManifestPath="manifests\AssetsPackage.appxmanifest">
<Files>
<File DestinationPath="**" SourcePath="common-binaries\**"/>
</Files>
</AssetPackage>
</PackageFamily>
</PackagingLayout>

View File

@@ -0,0 +1,2 @@
@echo off
powershell -File "%~dp0prepare-manifests.ps1" %1 %2 %3 %OTTD_VERSION%

View File

@@ -0,0 +1,42 @@
[CmdletBinding()]
[Alias()]
Param
(
# Output folder
[Parameter(Mandatory=$true, Position=0)]
$OutputFolder,
# Publisher ("CN=xyz")
[Parameter(Mandatory=$true, Position=1)]
$Publisher,
# IdentityName
[Parameter(Mandatory=$true, Position=2)]
$IdentityName,
# Version
[Parameter(Mandatory=$true, Position=3)]
$AppVersion
)
function Prepare-Manifest {
param (
$Architecture
)
(Get-Content "$($PSScriptRoot)\manifests\Package.appxmanifest").replace('$PUBLISHER$', $Publisher).replace('$IDENTITY_NAME$', $IdentityName).replace('$VERSION$', $AppVersion).replace('$ARCHITECTURE$', $Architecture) | Set-Content "$($OutputFolder)\Package-$($Architecture).appxmanifest"
}
# Prepare the application binary manifests
Prepare-Manifest x86
Prepare-Manifest x64
Prepare-Manifest arm64
# Prepare the assets package manifest
(Get-Content "$($PSScriptRoot)\manifests\AssetsPackage.appxmanifest").replace('$PUBLISHER$', $Publisher).replace('$IDENTITY_NAME$', $IdentityName).replace('$VERSION$', $AppVersion) | Set-Content "$($OutputFolder)\AssetsPackage.appxmanifest"
# Prepare the overall package manifest
(Get-Content "$($PSScriptRoot)\manifests\Package.appxmanifest").replace('$PUBLISHER$', $Publisher).replace('$IDENTITY_NAME$', $IdentityName).replace('$VERSION$', $AppVersion).replace(' ProcessorArchitecture="$ARCHITECTURE$"', '') | Set-Content "$($OutputFolder)\Package.appxmanifest"
# Copy the PackagingLayout XML file
(Get-Content "$($PSScriptRoot)\manifests\PackagingLayout.xml") | Set-Content "$($OutputFolder)\PackagingLayout.xml"

View File

@@ -0,0 +1,14 @@
@echo off
if [%1]==[] goto err
powershell -File "%~dp0set-version.ps1" %1 > "%temp%\ottd-set-version.bat"
if not errorlevel 0 goto err
call "%temp%\ottd-set-version.bat"
del /q "%temp%\ottd-set-version.bat"
@rem Version number will now be in %OTTD_VERSION%
goto :eof
:err
echo Please supply the path of openttd.exe as the argument to this batch file.

View File

@@ -0,0 +1,23 @@
[CmdletBinding()]
[Alias()]
Param
(
# EXE path
[Parameter(Mandatory=$true, Position=0)]
$ExePath
)
try
{
$versionInfo = (Get-Item "$ExePath").VersionInfo
# Generate the app version - the build number (MS calls it revision) is always 0 because the Windows Store requires that
$AppVersion = "$($versionInfo.FileMajorPart).$($versionInfo.FileMinorPart).$($versionInfo.FileBuildPart).0"
Write-Output "SET OTTD_VERSION=$($AppVersion)"
}
catch
{
Write-Output "@ECHO Error retrieving EXE version - did you provide a path?"
exit 1
}