From 3471ec702c90aa9a759fd9c9a2683bd3c33d7cb0 Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Sun, 10 Jul 2022 23:53:59 -0700 Subject: [PATCH] win: add sentry crash reporting --- .github/workflows/release.yml | 75 ++++++++++++++++++++++++++-------- CMakeLists.txt | 77 +++++++++++++++++++++++------------ output/_auto/buildpack.bat | 1 + src/guys.cpp | 39 ++++++++++++------ src/weapons.cpp | 12 +++--- src/zapp.cpp | 21 ++++++++++ src/zfix.h | 19 +++++++++ 7 files changed, 181 insertions(+), 63 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c84325c782..422fe5b600 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ on: default: false jobs: - check_date: + check-date: runs-on: ubuntu-latest outputs: should_run: ${{ steps.should_run.outputs.should_run }} @@ -40,7 +40,7 @@ jobs: if: ${{ github.event_name == 'schedule' }} run: test -z $(git rev-list --after="1 week" ${{ github.sha }}) && echo "::set-output name=should_run::false" - create_tag: + create-tag: runs-on: ubuntu-latest outputs: release_tag_name: ${{ steps.make-vars.outputs.release_tag_name }} @@ -77,11 +77,19 @@ jobs: echo "::set-output name=release_name::Nightly ${{ steps.current-time.outputs.formattedTime }}" fi + - name: Setup Sentry CLI + uses: mathieu-bour/setup-sentry-cli@1.2.0 + with: + token: ${{ secrets.SENTRY_TOKEN }} + organization: zeldaclassic + project: zelda-classic + - run: sentry-cli releases new ${{ steps.make-vars.outputs.release_tag_name }} + release-win: needs: - - check_date - - create_tag - if: ${{ needs.check_date.outputs.should_run != 'false' }} + - check-date + - create-tag + if: ${{ needs.check-date.outputs.should_run != 'false' }} runs-on: windows-2022 strategy: @@ -104,29 +112,39 @@ jobs: uses: crazy-max/ghaction-chocolatey@v1 with: args: install .github/dependencies.config -y + - name: Setup Sentry CLI + uses: mathieu-bour/setup-sentry-cli@1.2.0 + with: + token: ${{ secrets.SENTRY_TOKEN }} + organization: zeldaclassic + project: zelda-classic - run: bash .github/workflows/configure-signatures.sh win ${{ inputs.versiontype }} ${{ inputs.full_release }} ${{ inputs.number }} - - run: cmake . -A ${{ matrix.arrays.arch }} - - run: cmake --build . --config Release + - run: cmake . -A ${{ matrix.arrays.arch }} -DWANT_SENTRY=ON -DSENTRY_RELEASE_TAG=${{ needs.create-tag.outputs.release_tag_name }} + - run: cmake --build . --config RelWithDebInfo + - run: mv RelWithDebInfo Release - run: echo y | ./buildpack.bat working-directory: output/_auto - - run: mv output/_auto/buildpack.zip "output/_auto/${{ needs.create_tag.outputs.release_tag_name }}-${{ matrix.arrays.name }}.zip" + - run: mv output/_auto/buildpack.zip "output/_auto/${{ needs.create-tag.outputs.release_tag_name }}-${{ matrix.arrays.name }}.zip" + + - name: Upload debugging symbols + run: sentry-cli upload-dif ${{ needs.create-tag.outputs.release_tag_name }} --include-sources --wait Release - name: Release uses: softprops/action-gh-release@v1 with: - name: ${{ needs.create_tag.outputs.release_name }} - tag_name: ${{ needs.create_tag.outputs.release_tag_name }} - files: "output/_auto/${{ needs.create_tag.outputs.release_tag_name }}-${{ matrix.arrays.name }}.zip" + name: ${{ needs.create-tag.outputs.release_name }} + tag_name: ${{ needs.create-tag.outputs.release_tag_name }} + files: "output/_auto/${{ needs.create-tag.outputs.release_tag_name }}-${{ matrix.arrays.name }}.zip" prerelease: ${{ !inputs.full_release }} fail_on_unmatched_files: true generate_release_notes: true release-mac: needs: - - check_date - - create_tag - if: ${{ needs.check_date.outputs.should_run != 'false' }} + - check-date + - create-tag + if: ${{ needs.check-date.outputs.should_run != 'false' }} runs-on: macos-12 @@ -150,14 +168,35 @@ jobs: - run: ./buildpack_osx.sh working-directory: output/_auto - - run: mv output/_auto/ZeldaClassic.dmg "output/_auto/${{ needs.create_tag.outputs.release_tag_name }}-mac.dmg" + - run: mv output/_auto/ZeldaClassic.dmg "output/_auto/${{ needs.create-tag.outputs.release_tag_name }}-mac.dmg" - name: Release uses: softprops/action-gh-release@v1 with: - name: ${{ needs.create_tag.outputs.release_name }} - tag_name: ${{ needs.create_tag.outputs.release_tag_name }} - files: "output/_auto/${{ needs.create_tag.outputs.release_tag_name }}-mac.dmg" + name: ${{ needs.create-tag.outputs.release_name }} + tag_name: ${{ needs.create-tag.outputs.release_tag_name }} + files: "output/_auto/${{ needs.create-tag.outputs.release_tag_name }}-mac.dmg" prerelease: ${{ !inputs.full_release }} fail_on_unmatched_files: true generate_release_notes: true + + finalize: + needs: + - create-tag + - release-win + - release-mac + runs-on: ubuntu-latest + + steps: + - name: git clone + uses: actions/checkout@v2 + - name: Setup Sentry CLI + uses: mathieu-bour/setup-sentry-cli@1.2.0 + with: + token: ${{ secrets.SENTRY_TOKEN }} + organization: zeldaclassic + project: zelda-classic + - name: Finalize sentry + run: | + sentry-cli releases set-commits ${{ needs.create-tag.outputs.release_tag_name }} --auto + sentry-cli releases finalize ${{ needs.create-tag.outputs.release_tag_name }} diff --git a/CMakeLists.txt b/CMakeLists.txt index d53b8fc7d6..9cfe2289c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,11 @@ cmake_minimum_required(VERSION 3.5) -set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING INTERNAL FORCE) +set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo CACHE STRING INTERNAL FORCE) project (ZeldaClassic) set(USE_PCH FALSE CACHE BOOL "Use precompiled headers") set(UNITY_BUILD FALSE CACHE BOOL "Unity build") +set(WANT_SENTRY FALSE CACHE BOOL "Include Sentry for crash dump handling") +set(SENTRY_RELEASE_TAG "" CACHE STRING "Release tag for sentry") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -37,7 +39,7 @@ function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME) FILE(APPEND ${unit_build_file} "#include \"${CMAKE_SOURCE_DIR}/src/precompiled.h\"\n") # Add include statement for each translation unit foreach(source_file ${files} ) - FILE( APPEND ${unit_build_file} "#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n") + FILE( APPEND ${unit_build_file} "#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n") endforeach(source_file) # Complement list of translation units with the name of ub set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${unit_build_file} PARENT_SCOPE) @@ -76,7 +78,7 @@ if(NOT allegro5_POPULATED) add_subdirectory(${allegro5_SOURCE_DIR} ${allegro5_BINARY_DIR} EXCLUDE_FROM_ALL) # Allegro 5 CMakeLists sets CMAKE_CONFIGURATION_TYPES in a way that doesn't work for us, # so set it back to our value. - set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING INTERNAL FORCE) + set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo CACHE STRING INTERNAL FORCE) endif() # These include files are typically copied into the correct places via allegro's install @@ -120,7 +122,7 @@ include_directories(./include/zlib123) include_directories(./src) if(MSVC) - include_directories(./src/msvcCompat) +# include_directories(./src/msvcCompat) endif() set(ZCSOUNDSOURCES @@ -441,16 +443,16 @@ endif() add_executable(zelda ${ZELDA_CORE_SOURCES} ${ZELDA_GUI_SOURCES} ${ZELDA_SPRITE_SOURCES} ${ZELDA_SUBSCREEN_SOURCES} ${ZELDA_SCRIPTING_SOURCES} ${ZELDAEXTRASOURCES} ${ZELDA_MODULES}) target_compile_definitions(zelda PRIVATE IS_PLAYER) -target_link_libraries(zelda allegro_with_legacy) +target_link_libraries(zelda PRIVATE allegro_with_legacy) if(WIN32) - target_link_libraries(zelda zconsolelogger zcsound winmm ${IMAGELIBS} ${ZELDALIBSEXTRA}) + target_link_libraries(zelda PRIVATE zconsolelogger zcsound winmm ${IMAGELIBS} ${ZELDALIBSEXTRA}) elseif(LINUX) - target_link_libraries(zelda zconsolelogger zcsound ${IMAGELIBS} ${ZELDALIBSEXTRA}) + target_link_libraries(zelda PRIVATE zconsolelogger zcsound ${IMAGELIBS} ${ZELDALIBSEXTRA}) elseif(APPLE) - target_link_libraries(zelda zconsolelogger zcsound ${IMAGELIBS} ${ZELDALIBSEXTRA}) + target_link_libraries(zelda PRIVATE zconsolelogger zcsound ${IMAGELIBS} ${ZELDALIBSEXTRA}) endif() -target_link_libraries(zelda allegro_with_legacy) +target_link_libraries(zelda PRIVATE allegro_with_legacy) if(MSVC AND USE_PCH) set_target_properties(zelda PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h /Fp\"${ZCPrecompiledBinary}\"" OBJECT_DEPENDS "${ZCPrecompiledBinary}") @@ -484,7 +486,7 @@ find_package(Boost 1.74.0) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) add_definitions(-DHAS_BOOST) - add_executable(zquest ${ZQUEST_CORE_SOURCES} ${ZQUEST_GUI_SOURCES} ${ZQUEST_MISC_SOURCES} ${ZQUESTEXTRASOURCES} ${ZQUEST_MODULES}) + add_executable(zquest ${ZQUEST_CORE_SOURCES} ${ZQUEST_GUI_SOURCES} ${ZQUEST_MISC_SOURCES} ${ZQUESTEXTRASOURCES} ${ZQUEST_MODULES}) target_link_libraries(zquest PUBLIC allegro_with_legacy zconsolelogger zcsound ${IMAGELIBS} ${ZQUESTLIBSEXTRA}) @@ -532,7 +534,7 @@ elseif(LINUX) endif() add_executable(zlauncher ${LAUNCHER_SOURCES} ${LAUNCHER_GUI_SOURCES} ${LAUNCHEREXTRASOURCES}) -target_link_libraries(zlauncher allegro_with_legacy zconsolelogger ${LAUNCHERLIBSEXTRA}) +target_link_libraries(zlauncher PRIVATE allegro_with_legacy zconsolelogger ${LAUNCHERLIBSEXTRA}) target_compile_definitions(zlauncher PRIVATE IS_LAUNCHER) ############################################################# @@ -542,31 +544,36 @@ target_compile_definitions(zlauncher PRIVATE IS_LAUNCHER) add_executable(al5_example EXCLUDE_FROM_ALL src/al5_example_main.c) target_include_directories(al5_example PUBLIC ${allegro5_SOURCE_DIR}/include) target_include_directories(al5_example PUBLIC ${allegro5_BINARY_DIR}/include) -target_link_libraries(al5_example PUBLIC allegro_with_legacy allegro_font allegro_primitives) - -############################################################# -# Visual Studio -############################################################# - -set(zc_targets zquest zelda zlauncher zcsound zscript zconsolelogger) - -if (WIN32) - set_property(TARGET ${zc_targets} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "$(ProjectDir)$(Configuration)") - - set_property(GLOBAL PROPERTY USE_FOLDERS ON) - set_target_properties(zcsound gme dumb aldmb almp3 alogg PROPERTIES FOLDER Sound) - set_target_properties(allegro allegro_audio allegro_image allegro_font allegro_main allegro_primitives allegro_dialog allegro-legacy al5img algif5 al5_example PROPERTIES FOLDER Allegro) - set_target_properties(zconsole zconsolelogger PROPERTIES FOLDER ZConsole) -endif() +target_link_libraries(al5_example PRIVATE allegro_with_legacy allegro_font allegro_primitives) ############################################################# # Misc. ############################################################# +set(zc_targets zquest zelda zlauncher zcsound zscript zconsolelogger) +set(zc_apps zquest zelda zlauncher) set(zc_warnings -Werror=format ) +foreach(target IN LISTS zc_apps) + target_compile_definitions(${target} PRIVATE ZC_APP_NAME="${target}") +endforeach() + +if(WANT_SENTRY) + set(SENTRY_VERSION 0.4.18) + set(SENTRY_BACKEND crashpad) + set(SENTRY_BUILD_SHARED_LIBS OFF) + FetchContent_Declare(sentry URL https://github.com/getsentry/sentry-native/releases/download/${SENTRY_VERSION}/sentry-native.zip) + FetchContent_MakeAvailable(sentry) + + foreach(target IN LISTS zc_apps) + target_link_libraries(${target} PRIVATE sentry) + target_compile_definitions(${target} PRIVATE HAS_SENTRY) + target_compile_definitions(${target} PRIVATE SENTRY_RELEASE_TAG="${SENTRY_RELEASE_TAG}") + endforeach() +endif() + if (WIN32) list(APPEND zc_targets zconsole) endif() @@ -583,3 +590,19 @@ foreach(target IN LISTS zc_targets) target_compile_options(${target} PRIVATE ${zc_warnings}) endif() endforeach() + +############################################################# +# Visual Studio +############################################################# + +if (WIN32) + set_property(TARGET ${zc_targets} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "$(ProjectDir)$(Configuration)") + + set_property(GLOBAL PROPERTY USE_FOLDERS ON) + set_target_properties(zcsound gme dumb aldmb almp3 alogg PROPERTIES FOLDER Sound) + set_target_properties(allegro allegro_audio allegro_image allegro_font allegro_main allegro_primitives allegro_dialog allegro-legacy al5img algif5 al5_example PROPERTIES FOLDER Allegro) + set_target_properties(zconsole zconsolelogger PROPERTIES FOLDER ZConsole) + if(WANT_SENTRY) + set_target_properties(crashpad_client crashpad_compat crashpad_getopt crashpad_handler crashpad_handler_lib crashpad_minidump crashpad_snapshot crashpad_tools crashpad_util crashpad_zlib mini_chromium sentry PROPERTIES FOLDER Sentry) + endif() +endif() diff --git a/output/_auto/buildpack.bat b/output/_auto/buildpack.bat index c303379e20..12c608b521 100644 --- a/output/_auto/buildpack.bat +++ b/output/_auto/buildpack.bat @@ -31,6 +31,7 @@ copy /y "%rel%\zquest.exe" "%nb%\zquest.exe" >>%log% copy /y "%rel%\zscript.exe" "%nb%\zscript.exe" >>%log% copy /y "%rel%\zlauncher.exe" "%nb%\zlauncher.exe" >>%log% copy /y "%rel%\zconsole.exe" "%nb%\zconsole.exe" >>%log% +copy /y "%rel%\crashpad_handler.exe" "%nb%\crashpad_handler.exe" >>%log% copy /y "%rel%\*.dll" "%nb%" >>%log% echo Copying 'changelog.txt'... diff --git a/src/guys.cpp b/src/guys.cpp index b74a5945c0..c03426af65 100644 --- a/src/guys.cpp +++ b/src/guys.cpp @@ -5642,7 +5642,8 @@ int32_t enemy::takehit(weapon *w) // This obscure quest rule... if(get_bit(quest_rules,qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb)) { - double ddir=atan2(double(wpny-y),double(x-wpnx)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx)); wpnDir=zc_oldrand()&3; if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4))) @@ -9154,7 +9155,8 @@ void enemy::update_enemy_frame() tilerows = 2; int fakex = x + 8*(zc_max(1,txsz)-1); int fakey = y + 8*(zc_max(1,tysz)-1); - double ddir=atan2(double(fakey-(Hero.y)),double(Hero.x-fakex)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex)); int32_t lookat=zc_oldrand()&15; if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) @@ -11493,7 +11495,8 @@ bool eTrap::animate(int32_t index) { ox = x; oy = y; - double ddir=atan2(double(y-(Hero.y)),double(Hero.x-x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4))) { @@ -12281,7 +12284,8 @@ bool eProjectile::animate(int32_t index) removearmos(x,y); } - double ddir=atan2(double(y-(Hero.y)),double(Hero.x-x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4))) { @@ -12417,7 +12421,8 @@ bool eNPC::animate(int32_t index) { case 0: { - double ddir=atan2(double(y-(Hero.y)),double(Hero.x-x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4))) { @@ -12513,7 +12518,8 @@ void eSpinTile::facehero() } else { - double ddir=atan2(double(y-(Hero.y)),double(Hero.x-x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0)) { @@ -12570,7 +12576,8 @@ bool eSpinTile::animate(int32_t index) if(misc==96) { facehero(); - double ddir=atan2(double((Hero.y)-y),double(Hero.x-x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x)); angular=true; angle=ddir; step=zslongToFix(dstep*100); @@ -12643,7 +12650,8 @@ void eZora::facehero() } else { - double ddir=atan2(double(y-(Hero.y)),double(Hero.x-x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) { @@ -13350,7 +13358,8 @@ bool eStalfos::animate(int32_t index) } else //turn to face Hero { - double ddir=atan2(double(y-(Hero.y)),double(Hero.x-x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8))) { @@ -18274,7 +18283,8 @@ bool ePatra::animate(int32_t index) temp_y=circle_y; } - double ddir=atan2(double(temp_y),double(temp_x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x)); if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) { @@ -18529,7 +18539,8 @@ bool ePatra::animate(int32_t index) temp_y=circle_y; } - double ddir=atan2(double(temp_y),double(temp_x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x)); if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) { @@ -19097,7 +19108,8 @@ bool ePatraBS::animate(int32_t index) guys.spr(i)->y = temp_y; } - double ddir=atan2(double(temp_y),double(temp_x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x)); if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) { @@ -19147,7 +19159,8 @@ void ePatraBS::draw(BITMAP *dest) if(get_bit(quest_rules,qr_NEWENEMYTILES)) { - double ddir=atan2(double(y-(Hero.y)),double(Hero.x-x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) { diff --git a/src/weapons.cpp b/src/weapons.cpp index f164696908..3924ad9d63 100644 --- a/src/weapons.cpp +++ b/src/weapons.cpp @@ -866,7 +866,8 @@ void weapon::setAngle(double angletoset) void weapon::seekHero() { angular = true; - angle = atan2(double(HeroY()-y),double(HeroX()-x)); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + angle = atan2_MSVC2022_FIX(double(HeroY()-y),double(HeroX()-x)); doAutoRotate(); if(angle==-PI || angle==PI) dir=left; @@ -911,9 +912,9 @@ void weapon::seekEnemy(int32_t j) { return; } - - angle = atan2(double(GuyY(j)-y),double(GuyX(j)-x)); - doAutoRotate(); + + double _MSVC2022_tmp1, _MSVC2022_tmp2; + angle = atan2_MSVC2022_FIX(double(GuyY(j)-y),double(GuyX(j)-x)); if(angle==-PI || angle==PI) dir=left; else if(angle==-PI/2) dir=up; @@ -954,7 +955,8 @@ int32_t weapon::seekEnemy2(int32_t j) } //al_trace("Guy: %d, gx: %f, gy: %f, x: %f, y: %f\n", j, float(GuyX(j)), float(GuyY(j)), float(dummy_fix[0]), float(dummy_fix[1])); - angle = atan2(double(GuyY(j)-dummy_fix[1]),double(GuyX(j)-dummy_fix[0])); + double _MSVC2022_tmp1, _MSVC2022_tmp2; + angle = atan2_MSVC2022_FIX(double(GuyY(j)-dummy_fix[1]),double(GuyX(j)-dummy_fix[0])); doAutoRotate(); if(angle==-PI || angle==PI) dir=left; diff --git a/src/zapp.cpp b/src/zapp.cpp index c8de1cca92..66bb1c7ffa 100644 --- a/src/zapp.cpp +++ b/src/zapp.cpp @@ -1,9 +1,20 @@ #include "zapp.h" #include +#include #ifdef __APPLE__ #include #endif +#ifdef HAS_SENTRY +#define SENTRY_BUILD_STATIC 1 +#include "sentry.h" + +void sentry_atexit() +{ + sentry_close(); +} +#endif + bool is_in_osx_application_bundle() { #ifdef __APPLE__ @@ -15,6 +26,16 @@ bool is_in_osx_application_bundle() void common_main_setup(int argc, char **argv) { +#ifdef HAS_SENTRY + sentry_options_t *options = sentry_options_new(); + sentry_options_set_dsn(options, "https://133f371c936a4bc4bddec532b1d1304a@o1313474.ingest.sentry.io/6563738"); + sentry_options_set_release(options, "zelda-classic@" SENTRY_RELEASE_TAG); + sentry_options_set_handler_path(options, "crashpad_handler.exe"); + sentry_init(options); + sentry_set_tag("app", ZC_APP_NAME); + atexit(sentry_atexit); +#endif + // This allows for opening a binary from Finder and having ZC be in its expected // working directory (the same as the binary). Only used when not inside an application bundle, // and only for testing purposes really. See comment about `SKIP_APP_BUNDLE` in buildpack_osx.sh diff --git a/src/zfix.h b/src/zfix.h index 5a33903689..a1e1677b96 100644 --- a/src/zfix.h +++ b/src/zfix.h @@ -11,6 +11,25 @@ #define FIX_NAN 0 //std::numeric_limits::quiet_NaN() +// Weird internal compiler error, but only for RelWithDebInfo 32bit... +// Also may be only VS2020 +// +// double angle = atan2(double(y-(Hero.y)),double(Hero.x-x)) +// +// results in error: +// +// fatal error C1001: Internal compiler error +// +// Can avoid by using temporary variables. +// There's a lot of these, so this macro helps by making drop-in replacement simple. +// Usages of this macro must define these variables in scope somewhere: +// double _MSVC2022_tmp1, _MSVC2022_tmp2; +#define atan2_MSVC2022_FIX(x, y) (\ + _MSVC2022_tmp1 = x,\ + _MSVC2022_tmp2 = y,\ + atan2(_MSVC2022_tmp1, _MSVC2022_tmp2)\ +); + typedef int32_t ZLong; typedef int64_t zint64;