From beaea4f624f402d4108d5f5c3d0936eb7e00ed48 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Fri, 11 Feb 2022 11:56:31 +0100 Subject: [PATCH 01/11] Fix crash when giving commandline arguments with no console initialized --- src/TConsole.cpp | 4 ---- src/main.cpp | 8 ++++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/TConsole.cpp b/src/TConsole.cpp index 827881c..79d30a4 100644 --- a/src/TConsole.cpp +++ b/src/TConsole.cpp @@ -369,10 +369,6 @@ TConsole::TConsole() { mCommandline.set_history_limit(20); mCommandline.set_prompt("> "); BackupOldLog(); - bool success = mCommandline.enable_write_to_file("Server.log"); - if (!success) { - beammp_error("unable to open file for writing: \"Server.log\""); - } mCommandline.on_command = [this](Commandline& c) { try { auto cmd = c.get_command(); diff --git a/src/main.cpp b/src/main.cpp index a1c9354..8b2f3c5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,6 +77,7 @@ int main(int argc, char** argv) { int BeamMPServerMain(MainArguments Arguments) { setlocale(LC_ALL, "C"); + Application::InitializeConsole(); ArgsParser Parser; Parser.RegisterArgument({ "help" }, ArgsParser::NONE); Parser.RegisterArgument({ "version" }, ArgsParser::NONE); @@ -116,9 +117,12 @@ int BeamMPServerMain(MainArguments Arguments) { } } } - - Application::InitializeConsole(); + Application::SetSubsystemStatus("Main", Application::Status::Starting); + bool Success = Application::Console().Internal().enable_write_to_file("Server.log"); + if (!Success) { + beammp_error("unable to open file for writing: \"Server.log\""); + } SetupSignalHandlers(); From 5553aca0bb5c750f920bb9686a8850ce0ad7cfba Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Sat, 12 Feb 2022 22:08:49 +0100 Subject: [PATCH 02/11] set heartbeat status properly --- src/THeartbeatThread.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/THeartbeatThread.cpp b/src/THeartbeatThread.cpp index f5be47b..6efdd74 100644 --- a/src/THeartbeatThread.cpp +++ b/src/THeartbeatThread.cpp @@ -121,6 +121,9 @@ void THeartbeatThread::operator()() { beammp_error("Backend REFUSED the auth key. " + Message); } } + if (isAuth) { + Application::SetSubsystemStatus("Heartbeat", Application::Status::Good); + } } } From a982d5420290fd495edc96810cdc58072763dea4 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 17 Feb 2022 11:13:07 +0100 Subject: [PATCH 03/11] add debug build to windows github actions --- .github/workflows/cmake-windows.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml index 9ea76a7..aa9b43b 100644 --- a/.github/workflows/cmake-windows.yml +++ b/.github/workflows/cmake-windows.yml @@ -44,4 +44,15 @@ jobs: name: BeamMP-Server.exe path: ${{github.workspace}}/build-windows/Release/BeamMP-Server.exe + - name: Build debug + working-directory: ${{github.workspace}}/build-windows + shell: bash + run: | + cmake --build . --config Debug + + - name: Archive debug artifacts + uses: actions/upload-artifact@v2 + with: + name: BeamMP-Server-debug.exe + path: ${{github.workspace}}/build-windows/Debug/BeamMP-Server.exe From 86ad28abdccef3626534f2be880aab996ae3d758 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 17 Feb 2022 11:29:51 +0100 Subject: [PATCH 04/11] Microsoft (R) Windows (TM) needs deprecation --- .github/workflows/cmake-windows.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml index aa9b43b..e18328c 100644 --- a/.github/workflows/cmake-windows.yml +++ b/.github/workflows/cmake-windows.yml @@ -44,6 +44,13 @@ jobs: name: BeamMP-Server.exe path: ${{github.workspace}}/build-windows/Release/BeamMP-Server.exe + - name: Configure CMake for debug + shell: bash + working-directory: ${{github.workspace}}/build-windows + env: + beammp_sentry_url: ${{ secrets.BEAMMP_SECRET_SENTRY_URL }} + run: cmake $GITHUB_WORKSPACE -DSENTRY_BACKEND=breakpad -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE='${{ runner.workspace }}/b/vcpkg/scripts/buildsystems/vcpkg.cmake' -DVCPKG_TARGET_TRIPLET=x64-windows-static -DBEAMMP_SECRET_SENTRY_URL="$beammp_sentry_url" -DCMAKE_CXX_FLAGS="/bigobj" + - name: Build debug working-directory: ${{github.workspace}}/build-windows shell: bash From 687b4e4235d66d6a1eea602b152ca8699fafa614 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 17 Feb 2022 11:42:37 +0100 Subject: [PATCH 05/11] add bigobj flag --- .github/workflows/cmake-windows.yml | 7 ------- CMakeLists.txt | 4 ++++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml index e18328c..aa9b43b 100644 --- a/.github/workflows/cmake-windows.yml +++ b/.github/workflows/cmake-windows.yml @@ -44,13 +44,6 @@ jobs: name: BeamMP-Server.exe path: ${{github.workspace}}/build-windows/Release/BeamMP-Server.exe - - name: Configure CMake for debug - shell: bash - working-directory: ${{github.workspace}}/build-windows - env: - beammp_sentry_url: ${{ secrets.BEAMMP_SECRET_SENTRY_URL }} - run: cmake $GITHUB_WORKSPACE -DSENTRY_BACKEND=breakpad -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE='${{ runner.workspace }}/b/vcpkg/scripts/buildsystems/vcpkg.cmake' -DVCPKG_TARGET_TRIPLET=x64-windows-static -DBEAMMP_SECRET_SENTRY_URL="$beammp_sentry_url" -DCMAKE_CXX_FLAGS="/bigobj" - - name: Build debug working-directory: ${{github.workspace}}/build-windows shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index a2bdb67..27ba001 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,10 @@ endif() set(SENTRY_BACKEND breakpad) add_subdirectory("deps/sentry-native") +if (MSVC) + add_definitions(/bigobj) +endif () + message(STATUS "Setting compiler flags") if (WIN32) From 8ce3be03a349e4c1c6d81acfe4fcba9c16453fb1 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 17 Feb 2022 12:00:03 +0100 Subject: [PATCH 06/11] make bigobj a linker flag? --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27ba001..6cbe134 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ set(SENTRY_BACKEND breakpad) add_subdirectory("deps/sentry-native") if (MSVC) - add_definitions(/bigobj) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /bigobj") endif () message(STATUS "Setting compiler flags") From b09f5a401d8843399e3f31d5edb69e575794e5ff Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 10 Mar 2022 12:17:46 +0100 Subject: [PATCH 07/11] update lionkor/commandline to 1.0.0 (adds cursor left- and right movement) --- deps/commandline | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/commandline b/deps/commandline index 0d3e107..71240f6 160000 --- a/deps/commandline +++ b/deps/commandline @@ -1 +1 @@ -Subproject commit 0d3e1073c1005270dfad851c1f8c59f4ce29d8c1 +Subproject commit 71240f634b211d830679e7d2841b897c7c30dad9 From 299004b14eed773b1744714e50b1ad4e358ccaa6 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 10 Mar 2022 12:21:08 +0100 Subject: [PATCH 08/11] fix msvc /bigobj issue --- CMakeLists.txt | 2 +- Changelog.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cbe134..eedb3a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ set(SENTRY_BACKEND breakpad) add_subdirectory("deps/sentry-native") if (MSVC) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /bigobj") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") endif () message(STATUS "Setting compiler flags") diff --git a/Changelog.md b/Changelog.md index 28fb6cf..5bb611a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ # v3.0.1 - ADDED Backup URLs to UpdateCheck (will fail less often now) +- ADDED console cursor left and right movement (with arrow keys) and working HOME and END key (via github.com/lionkor/commandline) - FIXED a bug where, when run with --working-directory, the Server.log would still be in the original directory - FIXED a bug which could cause the plugin reload thread to spin at 100% if the reloaded plugin's didn't terminate - FIXED an issue which would cause servers to crash on mod download via SIGPIPE on POSIX From 359faee6964c6e9fa22c893b95c6cf5daacd7d33 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 10 Mar 2022 01:27:16 +0100 Subject: [PATCH 09/11] Fix Unicycle "infinite spawning" bug --- src/TServer.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/TServer.cpp b/src/TServer.cpp index a4328e2..cee40b3 100644 --- a/src/TServer.cpp +++ b/src/TServer.cpp @@ -174,7 +174,7 @@ bool TServer::IsUnicycle(TClient& c, const std::string& CarJson) { try { auto Car = nlohmann::json::parse(CarJson); const std::string jbm = "jbm"; - if (Car.contains(jbm) && Car["jbm"].is_string() && Car["jbm"] == "unicycle") { + if (Car.contains(jbm) && Car[jbm].is_string() && Car[jbm] == "unicycle") { return true; } } catch (const std::exception& e) { @@ -184,17 +184,12 @@ bool TServer::IsUnicycle(TClient& c, const std::string& CarJson) { } bool TServer::ShouldSpawn(TClient& c, const std::string& CarJson, int ID) { - - if (c.GetUnicycleID() > -1 && (c.GetCarCount() - 1) < Application::Settings.MaxCars) { - return true; - } - - if (IsUnicycle(c, CarJson)) { + if (IsUnicycle(c, CarJson) && c.GetUnicycleID() < 0) { c.SetUnicycleID(ID); return true; + } else { + return c.GetCarCount() < Application::Settings.MaxCars; } - - return Application::Settings.MaxCars > c.GetCarCount(); } void TServer::ParseVehicle(TClient& c, const std::string& Pckt, TNetwork& Network) { From a85fef15c28da6784a499152465793593b8a7864 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 10 Mar 2022 01:40:47 +0100 Subject: [PATCH 10/11] only use sentry if URL is specified, possibly fix stupid microsoft compiler error hey @microsoft, maybe don't have a limit on the size of obj files. --- CMakeLists.txt | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eedb3a0..6a36c83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,19 @@ set(SENTRY_BUILD_SHARED_LIBS OFF) if (MSVC) set(SENTRY_BUILD_RUNTIMESTATIC ON) endif() -set(SENTRY_BACKEND breakpad) +message(STATUS "Checking for Sentry URL") +# this is set by the build system. +# IMPORTANT: if you're building from source, just leave this empty +if (NOT DEFINED BEAMMP_SECRET_SENTRY_URL) + message(WARNING "No sentry URL configured. Sentry logging is disabled for this build. \ + This is not an error, and if you're building the BeamMP-Server yourself, this is expected and can be ignored.") + set(BEAMMP_SECRET_SENTRY_URL "") + set(SENTRY_BACKEND none) +else() + string(LENGTH ${BEAMMP_SECRET_SENTRY_URL} URL_LEN) + message(STATUS "Sentry URL is length ${URL_LEN}") + set(SENTRY_BACKEND breakpad) +endif() add_subdirectory("deps/sentry-native") if (MSVC) @@ -65,17 +77,6 @@ elseif (UNIX) endif (SANITIZE) endif () -message(STATUS "Checking for Sentry URL") -# this is set by the build system. -# IMPORTANT: if you're building from source, just leave this empty -if (NOT DEFINED BEAMMP_SECRET_SENTRY_URL) - message(WARNING "No sentry URL configured. Sentry logging is disabled for this build. \ - This is not an error, and if you're building the BeamMP-Server yourself, this is expected and can be ignored.") - set(BEAMMP_SECRET_SENTRY_URL "") -else() - string(LENGTH ${BEAMMP_SECRET_SENTRY_URL} URL_LEN) - message(STATUS "Sentry URL is length ${URL_LEN}") -endif() message(STATUS "Adding local source dependencies") # this has to happen before -DDEBUG since it wont compile properly with -DDEBUG From daa674f448715e12ce9e59a5073bbbd0f0b56ec2 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 10 Mar 2022 12:31:02 +0100 Subject: [PATCH 11/11] add infinite snowmen bug to changelog --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index 5bb611a..982c893 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ - ADDED Backup URLs to UpdateCheck (will fail less often now) - ADDED console cursor left and right movement (with arrow keys) and working HOME and END key (via github.com/lionkor/commandline) +- FIXED infinite snowmen / infinite unicycle spawning bug - FIXED a bug where, when run with --working-directory, the Server.log would still be in the original directory - FIXED a bug which could cause the plugin reload thread to spin at 100% if the reloaded plugin's didn't terminate - FIXED an issue which would cause servers to crash on mod download via SIGPIPE on POSIX