<ClCompile Include="..\..\src\load\item\item-loader-factory.cpp" />\r
<ClCompile Include="..\..\src\load\monster\monster-loader-factory.cpp" />\r
<ClCompile Include="..\..\src\load\player-class-specific-data-loader.cpp" />\r
+ <ClCompile Include="..\..\src\main-win\main-win-exception.cpp" />\r
<ClCompile Include="..\..\src\monster-race\race-brightness-mask.cpp" />\r
<ClCompile Include="..\..\src\monster-race\race-feature-mask.cpp" />\r
<ClCompile Include="..\..\src\monster\monster-pain-describer.cpp" />\r
<ClInclude Include="..\..\src\load\old\monster-flag-types-savefile50.h" />\r
<ClInclude Include="..\..\src\load\player-class-specific-data-loader.h" />\r
<ClInclude Include="..\..\src\load\savedata-old-flag-types.h" />\r
+ <ClInclude Include="..\..\src\main-win\main-win-exception.h" />\r
<ClInclude Include="..\..\src\market\bounty-type-definition.h" />\r
<ClInclude Include="..\..\src\monster-race\monster-aura-types.h" />\r
<ClInclude Include="..\..\src\monster-race\monster-kind-mask.h" />\r
<ClCompile Include="..\..\src\net\report-error.cpp">\r
<Filter>net</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\..\src\main-win\main-win-exception.cpp">\r
+ <Filter>main-win</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="..\..\src\combat\shoot.h">\r
<ClInclude Include="..\..\src\net\report-error.h">\r
<Filter>net</Filter>\r
</ClInclude>\r
+ <ClInclude Include="..\..\src\main-win\main-win-exception.h">\r
+ <Filter>main-win</Filter>\r
+ </ClInclude>\r
</ItemGroup>\r
<ItemGroup>\r
<None Include="..\..\src\wall.bmp" />\r
main-win/main-win-bg.cpp main-win/main-win-bg.h \
main-win/main-win-cfg-reader.cpp main-win/main-win-cfg-reader.h \
main-win/main-win-define.h \
+ main-win/main-win-exception.cpp main-win/main-win-exception.h \
main-win/main-win-file-utils.cpp main-win/main-win-file-utils.h \
main-win/main-win-mci.cpp main-win/main-win-mci.h \
main-win/main-win-menuitem.h \
#include "main-win/commandline-win.h"
#include "main-win/graphics-win.h"
#include "main-win/main-win-bg.h"
+#include "main-win/main-win-exception.h"
#include "main-win/main-win-file-utils.h"
#include "main-win/main-win-mci.h"
#include "main-win/main-win-menuitem.h"
}
/*!
- * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
+ * @brief ゲームのメインルーチン
*/
-int WINAPI WinMain(
- _In_ HINSTANCE hInst, [[maybe_unused]] _In_opt_ HINSTANCE hPrevInst, [[maybe_unused]] _In_ LPSTR lpCmdLine, [[maybe_unused]] _In_ int nCmdShow)
+int WINAPI game_main(_In_ HINSTANCE hInst)
{
setlocale(LC_ALL, "ja_JP");
hInstance = hInst;
quit(nullptr);
return 0;
}
+
+/*!
+ * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
+ */
+int WINAPI WinMain(
+ _In_ HINSTANCE hInst, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int)
+{
+ try {
+ return game_main(hInst);
+ } catch (const std::exception &e) {
+ handle_unexpected_exception(e);
+ return 1;
+ }
+}
+
#endif /* WINDOWS */
--- /dev/null
+#include "main-win/main-win-exception.h"
+#include "main-win/main-win-utils.h"
+#include "net/report-error.h"
+#include <sstream>
+
+/*!
+ * @brief 予期しない例外を処理する
+ *
+ * 予期しない例外が発生した場合、確認を取り例外のエラー情報を開発チームに送信する。
+ * その後、バグ報告ページを開くかどうか尋ね、開く場合はWebブラウザで開く。
+ *
+ * @param e 例外オブジェクト
+ */
+void handle_unexpected_exception(const std::exception &e)
+{
+ constexpr auto caption = _(L"予期しないエラー!", L"Unexpected error!");
+
+#if !defined(DISABLE_NET)
+ std::wstringstream report_confirm_msg_ss;
+ report_confirm_msg_ss
+ << to_wchar(e.what()).wc_str() << L"\n\n"
+ << _(L"開発チームにエラー情報を送信してよろしいですか?\n", L"Are you sure you want to send the error information to the development team?\n")
+ << _(L"※送信されるのはゲーム内の情報のみであり、個人情報が送信されることはありません。\n",
+ L"Only in-game information will be sent. No personal information will be sent.\n");
+
+ if (auto choice = MessageBoxW(NULL, report_confirm_msg_ss.str().data(), caption, MB_ICONEXCLAMATION | MB_YESNO | MB_ICONSTOP);
+ choice == IDYES) {
+ report_error(e.what());
+ }
+#endif
+
+ std::wstringstream issue_page_open_msg_ss;
+ issue_page_open_msg_ss
+ << _(L"エラー発生の詳しい状況を報告してくださると助かります。\n",
+ L"It would be helpful if you could report the detailed circumstances of the error.\n")
+ << _(L"バグ報告ページを開きますか?\n", L"Open bug report page?\n");
+
+ if (auto choice = MessageBoxW(NULL, issue_page_open_msg_ss.str().data(), caption, MB_ICONEXCLAMATION | MB_YESNO | MB_ICONSTOP);
+ choice == IDYES) {
+ constexpr auto url = "https://github.com/hengband/hengband/issues/new/choose";
+ ShellExecuteA(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
+ }
+};
--- /dev/null
+#pragma once
+
+#include <stdexcept>
+
+void handle_unexpected_exception(const std::exception &e);