diff --git a/.github/workflows/build_bin.yml b/.github/workflows/build_bin.yml new file mode 100644 index 00000000..f0b1fdec --- /dev/null +++ b/.github/workflows/build_bin.yml @@ -0,0 +1,253 @@ +name: Build binaries + +on: + push: + branches: + - "**" + + pull_request: + types: + - opened + - reopened + - synchronize + + workflow_dispatch: + +permissions: + contents: read + +env: + CONFIG_WIN: RelWithDebInfo + CONFIG_LINUX: Release + + +jobs: + + # ============================================================ + # Windows / MSVC + # ============================================================ + + windows: + name: Windows x64 / MSVC + runs-on: windows-2022 + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + submodules: recursive + + - name: Setup Python 3.14 + id: python + uses: actions/setup-python@v6 + with: + python-version: "3.14" + architecture: "x64" + + - name: Show environment + shell: pwsh + run: | + python --version + cmake --version + + Write-Host "Python:" + Get-Command python + + Write-Host "MSVC:" + & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" ` + -latest ` + -products * ` + -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ` + -property installationPath + + # README: bootstrap vcpkg + install DirectX DXC + - name: Prepare Windows dependencies + shell: cmd + run: | + call setup.bat + + - name: Configure + shell: pwsh + run: | + $pythonExe = "${{ steps.python.outputs.python-path }}" + $pythonRoot = Split-Path $pythonExe + + Write-Host "Python root: $pythonRoot" + + cmake -S . -B build ` + -G "Visual Studio 17 2022" ` + -A x64 ` + "-DPython3_ROOT_DIR=$pythonRoot" + + - name: Build + shell: pwsh + run: | + cmake --build build ` + --config $env:CONFIG_WIN ` + --parallel + + - name: Copy shaders + shell: pwsh + run: | + $output = "build/bin/$env:CONFIG_WIN" + + New-Item ` + -ItemType Directory ` + -Force ` + -Path "$output/shaders" | Out-Null + + Copy-Item ` + -Path "shaders/*" ` + -Destination "$output/shaders" ` + -Recurse ` + -Force + + - name: Upload Windows build + uses: actions/upload-artifact@v4 + with: + name: maszyna-windows-x64-${{ env.CONFIG_WIN }} + path: | + build/bin/${{ env.CONFIG_WIN }}/ + if-no-files-found: error + retention-days: 14 + + - name: Upload Windows debug symbols + uses: actions/upload-artifact@v4 + with: + name: maszyna-windows-x64-symbols-${{ env.CONFIG_WIN }} + path: | + build/pdb/${{ env.CONFIG_WIN }}/*.pdb + build/bin/${{ env.CONFIG_WIN }}/*.map + if-no-files-found: warn + retention-days: 14 + + + # ============================================================ + # Linux / GCC + # ============================================================ + + linux: + name: Linux x64 / GCC + runs-on: ubuntu-24.04 + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + submodules: recursive + + - name: Setup Python 3.14 + id: python + uses: actions/setup-python@v6 + with: + python-version: "3.14" + + - name: Install Linux dependencies + run: | + sudo apt-get update + + sudo apt-get install -y \ + build-essential \ + libgl1-mesa-dev \ + libglew-dev \ + libglfw3-dev \ + libpng-dev \ + libopenal-dev \ + libluajit-5.1-dev \ + libserialport-dev \ + libsndfile1-dev \ + xorg-dev \ + libxkbcommon-dev \ + libwayland-dev \ + wayland-protocols + + # + # Existing MaSzyna CI already builds OpenAL Soft 1.24.2, + # so retain that instead of relying only on Ubuntu's package. + # + - name: Build OpenAL Soft + run: | + git clone \ + --depth 1 \ + --branch 1.24.2 \ + https://github.com/kcat/openal-soft.git \ + /tmp/openal-soft + + cmake \ + -S /tmp/openal-soft \ + -B /tmp/openal-soft/build \ + -DCMAKE_BUILD_TYPE=Release \ + -DALSOFT_EXAMPLES=OFF \ + -DALSOFT_UTILS=OFF + + cmake \ + --build /tmp/openal-soft/build \ + --parallel "$(nproc)" + + sudo cmake \ + --install /tmp/openal-soft/build + + sudo ldconfig + + - name: Show environment + run: | + gcc --version + g++ --version + cmake --version + python --version + + - name: Configure + run: | + cmake \ + -S . \ + -B build \ + -DCMAKE_BUILD_TYPE="${CONFIG_LINUX}" \ + -DWITH_BETTER_RENDERER=OFF \ + -DWITH_ZMQ=OFF \ + -DWITH_OPENVR=OFF \ + -DUSE_LTO=OFF \ + -DPython3_EXECUTABLE="${{ steps.python.outputs.python-path }}" \ + -DCMAKE_CXX_FLAGS="-Wno-attributes -fno-inline-functions-called-once" + + - name: Build + run: | + cmake \ + --build build \ + --parallel "$(nproc)" + + - name: Prepare Linux Python environment + run: | + PYTHON_ROOT="$(python -c 'import sys; print(sys.base_prefix)')" + PYTHON_VERSION="$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')" + PYTHON_HOME="$GITHUB_WORKSPACE/build/bin/linuxpython64" + + echo "Python root: $PYTHON_ROOT" + echo "Python version: $PYTHON_VERSION" + echo "Embedded Python home: $PYTHON_HOME" + + python -m venv --copies "$PYTHON_HOME" + + cp -a \ + "$PYTHON_ROOT/lib/python${PYTHON_VERSION}/." \ + "$PYTHON_HOME/lib/python${PYTHON_VERSION}/" + + "$PYTHON_HOME/bin/python" -m pip install --upgrade pip + "$PYTHON_HOME/bin/python" -m pip install --no-cache-dir Pillow + + "$PYTHON_HOME/bin/python" -c "from PIL import Image; print('Pillow:', Image.__version__)" + + - name: Copy shaders + run: | + mkdir -p build/bin/shaders + cp -R shaders/. build/bin/shaders/ + + - name: Upload Linux build + uses: actions/upload-artifact@v4 + with: + name: maszyna-linux-x64-${{ env.CONFIG_LINUX }} + path: | + build/bin/ + if-no-files-found: error + retention-days: 14 diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index cd046eba..a6658494 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -1584,7 +1584,7 @@ class TMoverParameters double BatteryVoltage = 0.0; /*Winger - baterie w elektrykach*/ bool Battery = false; /*Czy sa zalaczone baterie*/ start_t BatteryStart = start_t::manual; - bool EpFuse = true; /*Czy sa zalavzone baterie*/ + bool EpFuse = true; /*Czy jest wlaczony hamulec EP*/ double EpForce = 0.0; /*Poziom zadanej sily EP*/ bool Signalling = false; /*Czy jest zalaczona sygnalizacja hamowania ostatniego wagonu*/ bool Radio = false; /*Czy jest zalaczony radiotelefon*/ diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 72808684..83c918e2 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -4497,7 +4497,7 @@ void TMoverParameters::UpdatePipePressure(double dt) if (EngineType != TEngineType::ElectricInductionMotor) { - double lbpa = LocalBrakePosA; + double lbpa = LocHandleTimeTraxx ? eim_localbrake : LocalBrakePosA; if (EIMCtrlType > 0 && UniCtrlIntegratedLocalBrakeCtrl) { lbpa = std::max(0.0, -eimic_real); @@ -4513,7 +4513,20 @@ void TMoverParameters::UpdatePipePressure(double dt) // in EIM stock the pneumatic local brake is normally driven only by the MED algorithm // (LocalBrakePosAEIM). When SplitEDPneumaticBrake is active the dedicated LocalBrake // lever should apply pneumatic pressure on the locomotive directly, bypassing MED. - double lbpa = SplitEDPneumaticBrake ? LocalBrakePosA : 0.0; + // LocHandleTimeTraxx also bypasses MED, but has 3 positions (brake-hold-unbrake). + double lbpa; + if (LocHandleTimeTraxx) + { + lbpa = eim_localbrake; + } + else if (SplitEDPneumaticBrake) // When LocHandleTimeTraxx and SplitEDPneumaticBrake are both active, lbpa is taken from LocHandleTimeTraxx, which is the desired behavior. + { + lbpa = LocalBrakePosA; + } + else + { + lbpa = 0.0; + } dpLocalValve = LocHandle->GetPF(std::max(lbpa, LocalBrakePosAEIM), Hamulec->GetBCP(), ScndPipePress, dt, 0); } @@ -7466,17 +7479,17 @@ void TMoverParameters::CheckEIMIC(double dt) } if (LocHandleTimeTraxx) { - if (LocalBrakeRatio() < 0.05) // pozycja 0 + if (LocalBrakeRatio() < 0.4) // pozycja 0, odhamowywanie { - eim_localbrake -= dt * 0.17; // zmniejszanie + eim_localbrake -= dt * 0.17; } - if (LocalBrakeRatio() > 0.15) // pozycja 2 + if (LocalBrakeRatio() > 0.6) // pozycja 2, zahamowywanie { - eim_localbrake += dt * 0.17; // wzrastanie + eim_localbrake += dt * 0.17; eim_localbrake = std::max(eim_localbrake, BrakePress / MaxBrakePress[0]); } - else + else // pozycja 1, utrzymanie cisnienia { if (eim_localbrake < Hamulec->GetEDBCP() / MaxBrakePress[0]) eim_localbrake = 0; diff --git a/McZapkie/Oerlikon_ESt.cpp b/McZapkie/Oerlikon_ESt.cpp index 1df5fe81..9559d305 100644 --- a/McZapkie/Oerlikon_ESt.cpp +++ b/McZapkie/Oerlikon_ESt.cpp @@ -237,26 +237,24 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr BrakeRes->Flow(dV); for (int i = 1; i < 4; ++i) - { Przekladniki[i]->Update(dt); - if (typeid(*Przekladniki[i]) == typeid(TRapid)) - { - RapidStatus = (BrakeDelayFlag & bdelay_R) == bdelay_R && (std::abs(Vel) > 70.0 || (std::abs(Vel) > 50.0 && RapidStatus) || RapidStaly); - Przekladniki[i]->SetRapidStatus(RapidStatus); - } - else if( typeid( *Przekladniki[i] ) == typeid( TPrzeciwposlizg ) ) - Przekladniki[i]->SetPoslizg((BrakeStatus & b_asb) == b_asb); - else if( typeid( *Przekladniki[ i ] ) == typeid( TPrzekED ) ) { - if( Vel < -15.0 ) - Przekladniki[ i ]->SetP( 0.0 ); - else - Przekladniki[ i ]->SetP( MaxBP * 3.0 ); - } - else if( typeid( *Przekladniki[i] ) == typeid( TPrzekCiagly ) ) - Przekladniki[i]->SetMult(LoadC); - else if( typeid( *Przekladniki[i] ) == typeid( TPrzek_PZZ ) ) - Przekladniki[i]->SetLBP(LBP); + + if( PrzekRapid != nullptr ) { + RapidStatus = (BrakeDelayFlag & bdelay_R) == bdelay_R && (std::abs(Vel) > 70.0 || (std::abs(Vel) > 50.0 && RapidStatus) || RapidStaly); + PrzekRapid->SetRapidStatus(RapidStatus); } + if( PrzekPoslizg != nullptr ) + PrzekPoslizg->SetPoslizg((BrakeStatus & b_asb) == b_asb); + if( PrzekED != nullptr ) { + if( Vel < -15.0 ) + PrzekED->SetP( 0.0 ); + else + PrzekED->SetP( MaxBP * 3.0 ); + } + if( PrzekCiagly != nullptr ) + PrzekCiagly->SetMult(LoadC); + if( PrzekPZZ != nullptr ) + PrzekPZZ->SetLBP(LBP); // przeplyw testowy miedzypojemnosci dV = PF(MPP, VVP, BVs(BCP)) + PF(MPP, CVP, CVs(BCP)); @@ -458,6 +456,12 @@ void TNESt3::SetSize( int const size, std::string const ¶ms ) // ustawianie static double const dOO1l = 0.907; static double const dOT1l = 0.524; + PrzekRapid.reset(); + PrzekPoslizg.reset(); + PrzekED.reset(); + PrzekCiagly.reset(); + PrzekPZZ.reset(); + if (contains( params, "ESt3" ) ) { Podskok = 0.7; @@ -467,23 +471,36 @@ void TNESt3::SetSize( int const size, std::string const ¶ms ) // ustawianie else { Podskok = -1.0; - Przekladniki[1] = std::make_shared(); - if (contains( params, "-s216" ) ) - Przekladniki[1]->SetRapidParams(2, 16); - else - Przekladniki[1]->SetRapidParams(2, 0); - Przekladniki[3] = std::make_shared(); + PrzekRapid = std::make_shared(); + Przekladniki[1] = PrzekRapid; + if (contains( params,"-ED") ) { - Przekladniki[1]->SetRapidParams(2, 18); - Przekladniki[3] = std::make_shared(); + PrzekRapid->SetRapidParams(2, 18); + PrzekED = std::make_shared(); + Przekladniki[3] = PrzekED; + } + else + { + if (contains( params, "-s216" ) ) + PrzekRapid->SetRapidParams(2, 16); + else + PrzekRapid->SetRapidParams(2, 0); + PrzekPoslizg = std::make_shared(); + Przekladniki[3] = PrzekPoslizg; } } if (contains(params,"AL2") ) - Przekladniki[2] = std::make_shared(); + { + PrzekCiagly = std::make_shared(); + Przekladniki[2] = PrzekCiagly; + } else if (contains(params,"PZZ") ) - Przekladniki[2] = std::make_shared(); + { + PrzekPZZ = std::make_shared(); + Przekladniki[2] = PrzekPZZ; + } else Przekladniki[2] = std::make_shared(); diff --git a/McZapkie/Oerlikon_ESt.h b/McZapkie/Oerlikon_ESt.h index a6b6f3d0..c1269185 100644 --- a/McZapkie/Oerlikon_ESt.h +++ b/McZapkie/Oerlikon_ESt.h @@ -17,6 +17,7 @@ http://mozilla.org/MPL/2.0/. Copyright (C) 2007-2014 Maciej Cierniak */ +#include #include #include "hamulce.h" // Pascal unit #include "friction.h" // Pascal unit @@ -76,12 +77,6 @@ class TPrzekladnik : public TReservoir // przekladnik (powtarzacz) TPrzekladnik() : TReservoir() {}; virtual void Update(double dt); - virtual void SetPoslizg(bool flag) {}; - virtual void SetP(double P) {}; - virtual void SetMult(double m) {}; - virtual void SetLBP(double P) {}; - virtual void SetRapidParams(double mult, double size) {}; - virtual void SetRapidStatus(bool rs) {}; }; class TRura : public TPrzekladnik // nieprzekladnik, rura laczaca @@ -185,7 +180,13 @@ class TNESt3 : public TBrake { private: std::shared_ptr CntrlRes; // zbiornik sterujacy std::shared_ptr Miedzypoj; // pojemnosc posrednia (urojona) do napelniania ZP i ZS - std::shared_ptr Przekladniki[ 4 ]; + std::array, 4> Przekladniki; // indeksowane od 1, indeks jest zarazem pojemnoscia + // bezposrednie wskazniki do przekladnikow dostrajanych w GetPF, inicjowane przy tworzeniu + std::shared_ptr PrzekRapid; + std::shared_ptr PrzekPoslizg; + std::shared_ptr PrzekED; + std::shared_ptr PrzekCiagly; + std::shared_ptr PrzekPZZ; double Nozzles[ dMAX ]; // dysze double BVM = 0.0; // przelozenie PG-CH // ValveFlag: byte; //polozenie roznych zaworkow diff --git a/README.md b/README.md index 0412be3d..47741a51 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [Website](https://eu07.pl/) · [Report an issue](https://github.com/MaSzyna-EU07/maszyna/issues) · [Community Discord](https://discord.gg/eu07) · [MaSzyna on Steam](https://store.steampowered.com/app/1033030/MaSzyna/) · [MaSzyna on Epic Games Store](https://store.epicgames.com/pl/p/maszyna-79052a) -![Discord](https://img.shields.io/discord/1019306167803056158?style=flat-square&logo=discord&label=Discord&labelColor=white) ![AppVeyor Build](https://img.shields.io/appveyor/build/Hirek193/maszyna?style=flat-square) ![Quality gate](https://img.shields.io/sonar/quality_gate/MaSzyna-EU07_maszyna?server=https%3A%2F%2Fsonarcloud.io&style=flat-square +![Discord](https://img.shields.io/discord/1019306167803056158?style=flat-square&logo=discord&label=Discord&labelColor=white) ![Github Actions](https://img.shields.io/github/actions/workflow/status/MaSzyna-EU07/maszyna/build_bin.yml?style=flat-square ) ![Quality gate](https://img.shields.io/sonar/quality_gate/MaSzyna-EU07_maszyna?server=https%3A%2F%2Fsonarcloud.io&style=flat-square ) ![Sonar cloud violations](https://img.shields.io/sonar/violations/MaSzyna-EU07_maszyna?server=https%3A%2F%2Fsonarcloud.io&format=long&style=flat-square ) [![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg?style=flat-square)](LICENSE) [![Last commit](https://img.shields.io/github/last-commit/MaSzyna-EU07/maszyna?style=flat-square&label=Last%20commit)](https://github.com/MaSzyna-EU07/maszyna/commits/master) [![Open issues](https://img.shields.io/github/issues/MaSzyna-EU07/maszyna?style=flat-square&label=Issues)](https://github.com/MaSzyna-EU07/maszyna/issues) [![Pull requests](https://img.shields.io/github/issues-pr/MaSzyna-EU07/maszyna?style=flat-square&label=Pull%20requests)](https://github.com/MaSzyna-EU07/maszyna/pulls) [![GitHub stars](https://img.shields.io/github/stars/MaSzyna-EU07/maszyna?style=flat-square&logo=github&label=Stars)](https://github.com/MaSzyna-EU07/maszyna/stargazers) [![GitHub forks](https://img.shields.io/github/forks/MaSzyna-EU07/maszyna?style=flat-square&logo=github&label=Forks)](https://github.com/MaSzyna-EU07/maszyna/forks) ![C++](https://img.shields.io/badge/C%2B%2B-17-00599C?style=flat-square&logo=cplusplus) ![Windows](https://img.shields.io/badge/platform-Windows-0078D6?style=flat-square&logo=windows) ![Linux](https://img.shields.io/badge/platform-Linux-FCC624?style=flat-square&logo=linux&logoColor=black) ![OpenGL](https://img.shields.io/badge/OpenGL-3.3%2B-5586A4?style=flat-square&logo=opengl) @@ -52,7 +52,7 @@ MaSzyna compiles and runs natively on **Linux** and **Windows**. Other platforms - [make](https://www.gnu.org/software/make/) -- A C++ compiler with C++14 support (we use some C++17 features, but older compilers may still work): +- A C++ compiler with C++20 support: - **Windows:** Visual Studio 2022 @@ -241,4 +241,4 @@ If detection still fails, padding the file (with comments) up to ~1 MB may hel - Source code: [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/) -- Assets: [Custom license](https://eu07.pl/theme/Maszyna/dokumentacja/inne/readme_pliki/en-licence.html) +- Assets: [Custom license](https://eu07.pl/docs/inne/readme_pliki/en-licence.html) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 3a189dc9..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,44 +0,0 @@ -version: '{build}' -image: Visual Studio 2022 - -# Używamy własnych kroków build -build: off - -# Zmienna z konfiguracją -environment: - CONFIG: RelWithDebInfo - -init: - - cmd: | - echo Build worker: %APPVEYOR_BUILD_WORKER_IMAGE% - ver - -install: - - cmd: | - git submodule update --init --recursive - call setup-ci.bat - -before_build: - - cmd: | - if not exist build mkdir build - cd build - cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=%CONFIG% -DPython3_ROOT_DIR=C:/Python314-x64 - -build_script: - - cmd: | - cmake --build . --config %CONFIG% --parallel - cd .. - -after_build: - - cmd: | - echo Copying shaders... - if not exist build\bin\%CONFIG%\shaders mkdir build\bin\%CONFIG%\shaders - xcopy /E /Y shaders build\bin\%CONFIG%\shaders\ - -artifacts: - - path: build\bin\%CONFIG%\*.exe - name: binaries - - path: build\pdb\%CONFIG%\*.pdb - name: symbols - - path: build\bin\%CONFIG%\shaders - name: shaders diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index c1e990c5..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,190 +0,0 @@ -jobs: - - job: validateshaders - pool: - vmImage: 'ubuntu-20.04' - displayName: 'Validate shaders' - steps: - - script: | - sudo apt-get update -y - sudo apt-get install -y glslang-tools - displayName: 'Install dependencies' - - script: | - cd ci_shadervalidator - ./build.sh - displayName: 'Build validator' - - script: | - cd ci_shadervalidator - ./validateshaders - displayName: 'Validate shaders' - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: 'shaders' - artifactName: shaders - displayName: 'Publish shaders' - - - job: ubuntu2004 - pool: - vmImage: 'Ubuntu-20.04' - displayName: 'Ubuntu 20.04 x86-64' - steps: - - script: | - sudo apt-get update -y - sudo apt-get install -y libglfw3-dev python3.14-dev libpng-dev libopenal-dev libluajit-5.1-dev libserialport-dev libsndfile1-dev - cd ref - git clone "https://github.com/chriskohlhoff/asio" --depth 1 --branch asio-1-12-2 -q - displayName: 'Install dependencies' - - script: | - mkdir build - cd build - cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_ZMQ=OFF -DWITH_OPENVR=OFF -DUSE_LTO=ON - cmake --build . - displayName: 'Build' - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: 'build/bin' - artifactName: binaries_linux - displayName: 'Publish binaries' - - - job: macos11 - pool: - vmImage: 'macOS-11' - displayName: 'MacOS 11 x86-64' - steps: - - script: | - sudo xcode-select -s /Applications/Xcode_12.4.app - displayName: 'Setup Xcode' - - script: | - cd /tmp - wget https://s2.milek7.pl/macos_vcpkg_cache_x64.tar.gz - tar -xf macos_vcpkg_cache_x64.tar.gz - mv tmp/vcpkg vcpkg - rmdir tmp - rm macos_vcpkg_cache_x64.tar.gz - displayName: 'Install dependencies' - - script: | - mkdir build - cd build - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_TOOLCHAIN_FILE=/tmp/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-osx -DWITH_ZMQ=OFF -DWITH_OPENVR=OFF -DWITH_UART=OFF -DUSE_LTO=ON -DWITH_LUA=OFF - cmake --build . - displayName: 'Build' - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: 'build/bin' - artifactName: binaries_macos - displayName: 'Publish binaries' - - - job: macos11_arm64 - pool: - vmImage: 'macOS-11' - displayName: 'MacOS 11 ARM64' - steps: - - script: | - sudo xcode-select -s /Applications/Xcode_12.4.app - displayName: 'Setup Xcode' - - script: | - cd /tmp - wget https://s2.milek7.pl/macos_vcpkg_cache_arm64.tar.gz - tar -xf macos_vcpkg_cache_arm64.tar.gz - mv tmp/vcpkg vcpkg - rmdir tmp - rm macos_vcpkg_cache_arm64.tar.gz - displayName: 'Install dependencies' - - script: | - mkdir build - cd build - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_TOOLCHAIN_FILE=/tmp/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=arm64-osx -DWITH_ZMQ=OFF -DWITH_OPENVR=OFF -DWITH_UART=OFF -DUSE_LTO=ON -DWITH_LUA=OFF - cmake --build . - displayName: 'Build' - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: 'build/bin' - artifactName: binaries_macos_arm64 - displayName: 'Publish binaries' - - - job: windows_x64 - pool: - vmImage: 'windows-2019' - displayName: 'Windows VS2019 x86-64' - steps: - - script: | - cd ref - git clone "https://github.com/chriskohlhoff/asio" --depth 1 --branch asio-1-12-2 -q - curl -o crashpad.zip "http://get.backtrace.io/crashpad/builds/release/x86-64/crashpad-2020-07-01-release-x64-558c9614e3819179f30b92541450f5ac643afce5.zip" - unzip crashpad.zip - move crashpad-2020-07-01-release-x64-558c9614e3819179f30b92541450f5ac643afce5 crashpad - displayName: 'Download extra dependencies' - - script: | - mkdir build - cd build - cmake .. -A x64 -DUSE_LTO=ON -DWITH_CRASHPAD=ON - cmake --build . --config RelWithDebInfo - displayName: 'Build' - - script: | - cd build - 7z a package.zip .\bin\RelWithDebInfo\*.exe .\pdb\RelWithDebInfo\*.pdb - curl --data-binary @package.zip -H "Expect:" "https://eu07.sp.backtrace.io:6098/post?format=symbols&token=4eeba9395fae661927e23679fc36f2237416ec056ef75399e894d597ad518c6c" - del .\bin\RelWithDebInfo\*.iobj - del .\bin\RelWithDebInfo\*.ipdb - displayName: 'Upload symbols' - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: 'build/bin' - artifactName: binaries_win64 - displayName: 'Publish binaries' - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: 'build/package.zip' - artifactName: symbols_win64 - displayName: 'Publish symbols' - - - job: windows_x64_dbg - pool: - vmImage: 'windows-2019' - displayName: 'Windows VS2019 Debug' - steps: - - script: | - cd ref - git clone "https://github.com/chriskohlhoff/asio" --depth 1 --branch asio-1-12-2 -q - displayName: 'Download extra dependencies' - - script: | - mkdir build - cd build - cmake .. -A x64 - cmake --build . --config Debug - displayName: 'Build' - - - job: windows_x32 - pool: - vmImage: 'windows-2019' - displayName: 'Windows VS2019 x86' - steps: - - script: | - cd ref - git clone "https://github.com/chriskohlhoff/asio" --depth 1 --branch asio-1-12-2 -q - curl -o crashpad.zip "http://get.backtrace.io/crashpad/builds/release/x86/crashpad-2020-07-01-release-x86-558c9614e3819179f30b92541450f5ac643afce5.zip" - unzip crashpad.zip - move crashpad-2020-07-01-release-x86-558c9614e3819179f30b92541450f5ac643afce5 crashpad - displayName: 'Download extra dependencies' - - script: | - mkdir build - cd build - cmake .. -A Win32 -T v141_xp -DUSE_LTO=ON -DWITH_CRASHPAD=ON - cmake --build . --config RelWithDebInfo - displayName: 'Build' - - script: | - cd build - 7z a package.zip .\pdb\RelWithDebInfo\*.pdb - curl --data-binary @package.zip -H "Expect:" "https://eu07.sp.backtrace.io:6098/post?format=symbols&token=4eeba9395fae661927e23679fc36f2237416ec056ef75399e894d597ad518c6c" - del .\bin\RelWithDebInfo\*.iobj - del .\bin\RelWithDebInfo\*.ipdb - displayName: 'Upload symbols' - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: 'build/bin' - artifactName: binaries_win32 - displayName: 'Publish binaries' - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: 'build/package.zip' - artifactName: symbols_win32 - displayName: 'Publish symbols' diff --git a/betterRenderer/CMakeLists.txt b/betterRenderer/CMakeLists.txt index 1bd30675..d28c7b55 100644 --- a/betterRenderer/CMakeLists.txt +++ b/betterRenderer/CMakeLists.txt @@ -71,7 +71,6 @@ target_compile_definitions(${LIBMANUL_NAME} PRIVATE GLM_FORCE_SWIZZLE GLM_FORCE_CTOR_INIT GLM_FORCE_INLINE - GLM_FORCE_DEFAULT_ALIGNED_GENTYPES GLM_FORCE_INTRINSICS) target_compile_definitions(${LIBMANUL_NAME} PRIVATE diff --git a/betterRenderer/mashadercompiler/src/shader_compiler.cpp b/betterRenderer/mashadercompiler/src/shader_compiler.cpp index 42cc96e5..20b3b0c3 100644 --- a/betterRenderer/mashadercompiler/src/shader_compiler.cpp +++ b/betterRenderer/mashadercompiler/src/shader_compiler.cpp @@ -9,6 +9,8 @@ int MaShaderCompiler::Run() { ParseOptions(); Init(); m_shader_path = m_project_path.parent_path(); + m_shader_path.make_preferred(); + YAML::Node src = YAML::LoadFile((m_project_path).generic_string()); create_directories(m_output_path); @@ -47,6 +49,7 @@ void MaShaderCompiler::Init() { const char *shader_path = getenv("shader_path"); if (shader_path) { m_shader_path = shader_path; + m_shader_path.make_preferred(); std::cout << "shader path: " << m_shader_path.generic_string() << std::endl; } else { m_shader_path = ""; @@ -62,6 +65,9 @@ YAML::Binary MaShaderCompiler::CompileShaderToBlob( std::vector> defines, std::string target, ShaderPlatform platform) { file_name.replace_extension(".hlsl"); + // Convert to native format since the name comes from the project + // file with forward slashes + file_name.make_preferred(); static std::unordered_map targets{ {"compute", L"cs_6_0"}, {"vertex", L"vs_6_0"}, {"hull", L"hs_6_0"}, {"domain", L"ds_6_0"}, {"geometry", L"gs_6_0"}, {"pixel", L"ps_6_0"}}; @@ -74,7 +80,7 @@ YAML::Binary MaShaderCompiler::CompileShaderToBlob( } RefCountPtr source_blob; - if (FAILED(m_dxc_utils->LoadFile(file_name.generic_wstring().c_str(), nullptr, + if (FAILED(m_dxc_utils->LoadFile(file_name.wstring().c_str(), nullptr, &source_blob))) { return {}; } @@ -84,8 +90,8 @@ YAML::Binary MaShaderCompiler::CompileShaderToBlob( Source.Encoding = DXC_CP_ACP; std::vector include_paths{ - m_shader_path.generic_wstring(), - file_name.parent_path().generic_wstring()}; + m_shader_path.wstring(), + file_name.parent_path().wstring()}; std::vector args; diff --git a/betterRenderer/mashadercompiler/src/shader_compiler.hpp b/betterRenderer/mashadercompiler/src/shader_compiler.hpp index 45f00976..f2d8ed49 100644 --- a/betterRenderer/mashadercompiler/src/shader_compiler.hpp +++ b/betterRenderer/mashadercompiler/src/shader_compiler.hpp @@ -26,6 +26,10 @@ class MaShaderCompiler { std::filesystem::path m_output_path; private: + // Stored in the native format, since DXC does not accept forward + // slashes in UNC paths. Use wstring() to retrieve it in native + // format or generic_wstring() to get the canonical forward slash + // format. std::filesystem::path m_shader_path; bool m_generate_debug = false; void ParseOptions(); diff --git a/launcher/launcheruilayer.cpp b/launcher/launcheruilayer.cpp index bf9dddb0..91974bbc 100644 --- a/launcher/launcheruilayer.cpp +++ b/launcher/launcheruilayer.cpp @@ -12,7 +12,7 @@ launcher_ui::launcher_ui() : m_scenery_scanner(m_vehicles_bank), m_scenerylist_p add_external_panel(&m_keymapper_panel); add_external_panel(&m_vehiclepicker_panel); - open_panel(&m_vehiclepicker_panel); + open_panel(&m_scenerylist_panel); m_suppress_menu = true; } diff --git a/shaders/mat_colored.frag b/shaders/mat_colored.frag index 47b350f3..80d1d546 100644 --- a/shaders/mat_colored.frag +++ b/shaders/mat_colored.frag @@ -9,9 +9,9 @@ in vec4 f_clip_future_pos; #param (color, 0, 0, 4, diffuse) #param (diffuse, 1, 0, 1, diffuse) -#param (specular, 1, 1, 1, specular) -#param (reflection, 1, 2, 1, zero) -#param (glossiness, 1, 3, 1, glossiness) +#param (specular, 0.2, 0.2, 0.2, specular) +#param (reflection, 0.5, 0.5, 0.5, zero) +#param (glossiness, 0.5, 0.5, 0.5, glossiness) layout(location = 0) out vec4 out_color; #if MOTIONBLUR_ENABLED diff --git a/shaders/mat_default.frag b/shaders/mat_default.frag index 826dedee..42f1adaa 100644 --- a/shaders/mat_default.frag +++ b/shaders/mat_default.frag @@ -38,10 +38,10 @@ void main() vec3 fragcolor = ambient; vec3 fragnormal = normalize(f_normal); float reflectivity = param[1].z; - float specularity = (tex_color.r + tex_color.g + tex_color.b) * 0.5; + //float specularity = (tex_color.r + tex_color.g + tex_color.b) * 0.5; glossiness = abs(param[1].w); - fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone); + fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, 0, shadow_tone); vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult); /* float distance = dot(f_pos.xyz, f_pos.xyz); diff --git a/shaders/mat_reflmap.frag b/shaders/mat_reflmap.frag index 3b02e092..5695ee3f 100644 --- a/shaders/mat_reflmap.frag +++ b/shaders/mat_reflmap.frag @@ -44,7 +44,7 @@ void main() float specularity = (tex_color.r + tex_color.g + tex_color.b) * 0.5; glossiness = abs(param[1].w); - fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone); + fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, 0, shadow_tone); if(alphatestfail) fragcolor.r = 1.0; diff --git a/shaders/tonemapping.glsl b/shaders/tonemapping.glsl index 9dc74a72..863fe0fe 100644 --- a/shaders/tonemapping.glsl +++ b/shaders/tonemapping.glsl @@ -44,7 +44,7 @@ vec3 filmic(vec3 x) // AgX tonemapping based on nxrighthere / Missing Deadlines implementation. // 0: Default, 1: Golden, 2: Punchy #ifndef AGX_LOOK -#define AGX_LOOK 2 +#define AGX_LOOK 0 #endif vec3 AgxDefaultContrastApprox(vec3 x) @@ -109,8 +109,8 @@ vec3 AgxLook(vec3 val) vec3 offset = vec3(0.0); vec3 slope = vec3(1.0); - vec3 power = vec3(1.0); - float sat = 1.0; + vec3 power = vec3(1.6); + float sat = 0.9; #if AGX_LOOK == 1 // Golden diff --git a/sonar-project.properties b/sonar-project.properties index 89a6e780..2e3fc88b 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -7,3 +7,7 @@ sonar.sourceEncoding=UTF-8 # Exclusions sonar.exclusions=betterRenderer/**,ref/**,imgui/**,stb/**,build/**,bw-output/** + +# Excluding all files from coverage making the gate skip that +# instead of failing it. +sonar.coverage.exclusions=**/* diff --git a/stdafx.h b/stdafx.h index b1e94b51..f2b37719 100644 --- a/stdafx.h +++ b/stdafx.h @@ -99,7 +99,6 @@ #define GLM_FORCE_CTOR_INIT #ifdef _MSC_VER #define GLM_FORCE_INLINE -#define GLM_FORCE_DEFAULT_ALIGNED_GENTYPES #endif #define GLM_FORCE_INTRINSICS #include diff --git a/utilities/Globals.cpp b/utilities/Globals.cpp index 332524fb..0ab064b4 100644 --- a/utilities/Globals.cpp +++ b/utilities/Globals.cpp @@ -223,6 +223,12 @@ bool global_settings::ConfigParseGraphics(cParser& Parser, const std::string& to return true; } + if (token == "targetfps") + { + ParseOne(Parser, targetfps, 1, false); + return true; + } + if (token == "heightbase") { ParseOne(Parser, fDistanceFactor, 1, false); diff --git a/utilities/Globals.h b/utilities/Globals.h index 729b7cbc..c4bd26f6 100644 --- a/utilities/Globals.h +++ b/utilities/Globals.h @@ -133,7 +133,7 @@ struct global_settings { float ShakingMultiplierRL {1.f}; // mnożnik bujania kamera lewo/prawo float ShakingMultiplierUD {1.f}; // mnożnik bujania kamera gora/dol float fDistanceFactor{ 1.f }; // baza do przeliczania odległości dla LoD - float targetfps{ 0.0f }; + float targetfps{ 60.0f }; bool bFullScreen{ false }; bool VSync{ false }; bool bWireFrame{ false }; @@ -224,7 +224,8 @@ struct global_settings { {"train", &uart_conf.trainenable}, {"local", &uart_conf.localenable}, {"radiovolume", &uart_conf.radiovolumeenable}, - {"radiochannel", &uart_conf.radiochannelenable} + {"radiochannel", &uart_conf.radiochannelenable}, + {"dynamicbrake", &uart_conf.dynamicenable}, }; #endif #ifdef WITH_ZMQ diff --git a/utilities/uart.cpp b/utilities/uart.cpp index 70b8d553..fcaa5bcc 100644 --- a/utilities/uart.cpp +++ b/utilities/uart.cpp @@ -506,6 +506,19 @@ void uart_input::poll() 0 ); } + if (true == conf.dynamicenable) + { + // dynamic brake 8 bit + double const position{(float)(buffer[13] - conf.dynamicbrakemin) / (conf.dynamicbrakemax - conf.dynamicbrakemin)}; + + relay.post( + user_command::dynamicbrakecontrollerset, + position, + 0, + GLFW_PRESS, + 0 + ); + } old_packet = buffer; } diff --git a/utilities/uart.h b/utilities/uart.h index a418dc22..1a0f344b 100644 --- a/utilities/uart.h +++ b/utilities/uart.h @@ -53,6 +53,8 @@ public: float lvmax = 150.0f; float lvuart = 65535.0f; float tachoscale = 1.0f; + float dynamicbrakemin = 0.0f; + float dynamicbrakemax = 255.0f; bool mainenable = true; bool scndenable = true; @@ -60,6 +62,7 @@ public: bool localenable = true; bool radiovolumeenable = false; bool radiochannelenable = false; + bool dynamicenable = false; bool debug = false; diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 54f97bd8..0cfad5c6 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -2236,7 +2236,10 @@ void TController::AutoRewident() } BrakeSystem = consist_brake_system(); - mvOccupied->EpFuseSwitch( BrakeSystem == TBrakeSystem::ElectroPneumatic ); + // Change the EP fuse state only when AI is in charge, don't fiddle with controls when the user is controlling the vehicle + if (AIControllFlag) { + mvOccupied->EpFuseSwitch(BrakeSystem == TBrakeSystem::ElectroPneumatic); + } if( OrderCurrentGet() & ( Obey_train | Bank ) ) { // 4. Przeliczanie siły hamowania diff --git a/vehicle/train/TrainState.cpp b/vehicle/train/TrainState.cpp index a6508680..c29af861 100644 --- a/vehicle/train/TrainState.cpp +++ b/vehicle/train/TrainState.cpp @@ -694,6 +694,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("mainctrl_pos_count", mvControlled->MainCtrlPosNo); dict->insert("main_ctrl_actual_pos", mvControlled->MainCtrlActualPos); dict->insert("scndctrl_pos", mvControlled->ScndCtrlPos); + dict->insert("dynamicbrake_pos", mvControlled->DynamicBrakeCtrlPos); dict->insert("scnd_ctrl_actual_pos", mvControlled->ScndCtrlActualPos); dict->insert("brakectrl_pos", mvControlled->fBrakeCtrlPos); dict->insert("localbrake_pos", mvControlled->LocalBrakePosA); diff --git a/world/Event.cpp b/world/Event.cpp index eb679e72..4e042b29 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -1014,6 +1014,13 @@ whois_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) { void whois_event::run_() { + if( m_activator == nullptr ) { + // no triggering vehicle to report on - most likely whois was launched from a + // scenery event chain rather than a track/isolation crossing + WriteLog( "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - no activator, event ignored" ); + return; + } + for( auto &target : m_targets ) { auto *targetcell { static_cast( std::get( target ) ) }; if( targetcell == nullptr ) { continue; } @@ -1129,20 +1136,28 @@ whois_event::run_() { + "[engine power: " + to_string( m_activator->MoverParameters->Power, 2 ) + "]" ); } // +0 - else if( m_activator->Mechanik ) { - if( m_activator->Mechanik->primary() ) { // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera! + else { + // same owner selection as the +8/+16/+24/+32/+40/+48 branches above: fall back to + // the consist's controlling vehicle if the activator itself isn't one (e.g. a wagon + // triggered the event ahead of its locomotive) - +0 used to require the activator's + // own Mechanik and silently produce nothing for a wagon-triggered whois + auto const *owner { ( + m_activator->Mechanik != nullptr && m_activator->Mechanik->primary() ? + m_activator->Mechanik : + m_activator->ctOwner ) }; + if( owner != nullptr ) { targetcell->UpdateValues( - m_activator->Mechanik->TrainName(), - m_activator->Mechanik->StationCount() - m_activator->Mechanik->StationIndex(), // ile przystanków do końca - m_activator->Mechanik->IsStop() ? + owner->TrainName(), + owner->StationCount() - owner->StationIndex(), // ile przystanków do końca + owner->IsStop() ? 1 : 0, // 1, gdy ma tu zatrzymanie m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); WriteLog( "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " - + "[train: " + m_activator->Mechanik->TrainName() + "], " - + "[stations left: " + std::to_string( m_activator->Mechanik->StationCount() - m_activator->Mechanik->StationIndex() ) + "], " - + "[stop at next station: " + ( m_activator->Mechanik->IsStop() ? "yes" : "no") + "]" ); + + "[train: " + owner->TrainName() + "], " + + "[stations left: " + std::to_string( owner->StationCount() - owner->StationIndex() ) + "], " + + "[stop at next station: " + ( owner->IsStop() ? "yes" : "no") + "]" ); } } } @@ -2195,7 +2210,13 @@ message_event::export_as_text_( std::ostream &Output ) const { basic_event * make_event( cParser &Input, scene::scratch_data &Scratchpad ) { - auto const name = ToLower( Input.getToken() ); + // getToken() already lowercases ASCII letters via the parser's toLowerChar(), + // which deliberately leaves bytes >= 0x80 untouched. The extra ToLower() here + // ran std::tolower() over every byte, so under a non-"C" global locale it + // remapped cp1250 uppercase accented letters (e.g. 0xAF -> 0xBF) - producing a + // registered name that no lookup site (Track::AssignEvents, child-event and + // launcher resolution) could match, since those normalize with the parser only. + auto const name = Input.getToken(); auto const type = Input.getToken(); basic_event *event { nullptr };