Permalink
Browse files

Reimplemented CrashRpt

  • Loading branch information...
1 parent 4ce3c80 commit 07d34bb47649c7020a8998e4850ef791bf20ab34 @AnotherFoxGuy AnotherFoxGuy committed Nov 15, 2016
Showing with 130 additions and 16 deletions.
  1. +29 −14 DEPENDENCIES.md
  2. +3 −2 cmake/DependenciesConfig.cmake
  3. +4 −0 source/main/CMakeLists.txt
  4. +94 −0 source/main/main.cpp
View
@@ -16,7 +16,8 @@ Rigs of Rods uses 3rd party libraries licensed under the following licenses:
| pthreads | Threads | LGPLv2.1 |
| boost | advanced C++ functions | Boost Software License 1.0 |
| wxWidgets | cross-platform GUI system | wxWindows 3.1 |
-| UTFCpp | UTF-8 validation/conversion | Boost Software License 1.0 |
+| UTFCpp | UTF-8 validation/conversion | Boost Software License 1.0 |
+| CrashRpt | Crash reporting system | BSD New |
@@ -52,20 +53,20 @@ The zlib/libpng License
Copyright (c) 2005-2010 Phillip Castaneda (pjcast -- www.wreckedgames.com)
-This software is provided 'as-is', without any express or implied warranty. In no
-event will the authors be held liable for any damages arising from the use of this
+This software is provided 'as-is', without any express or implied warranty. In no
+event will the authors be held liable for any damages arising from the use of this
software.
-Permission is granted to anyone to use this software for any purpose, including
-commercial applications, and to alter it and redistribute it freely, subject to the
+Permission is granted to anyone to use this software for any purpose, including
+commercial applications, and to alter it and redistribute it freely, subject to the
following restrictions:
- 1. The origin of this software must not be misrepresented; you must not claim that
- you wrote the original software. If you use this software in a product,
- an acknowledgment in the product documentation would be appreciated
+ 1. The origin of this software must not be misrepresented; you must not claim that
+ you wrote the original software. If you use this software in a product,
+ an acknowledgment in the product documentation would be appreciated
but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
+ 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
@@ -244,12 +245,12 @@ DEALINGS IN THE SOFTWARE.
WXWINDOWS LIBRARY LICENCE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
+
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public Licence as published by
the Free Software Foundation; either version 2 of the Licence, or (at
your option) any later version.
-
+
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
@@ -282,11 +283,25 @@ DEALINGS IN THE SOFTWARE.
accordingly.
4. If you write modifications of your own for this library, it is your
- choice whether to permit this exception to apply to your modifications.
+ choice whether to permit this exception to apply to your modifications.
If you do not wish that, you must delete the exception notice from such
code and/or adjust the licensing conditions notice accordingly.
```
+### CrashRpt
+```
+Copyright (c) <YEAR>, <OWNER>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+```
## Fonts:
```
@@ -334,7 +349,7 @@ Fonts, only if the fonts are renamed to names not containing either
the words "Tavmjong Bah" or the word "Arev".
This License becomes null and void to the extent applicable to Fonts
-or Font Software that has been modified and is distributed under the
+or Font Software that has been modified and is distributed under the
"Tavmjong Bah Arev" names.
The Font Software may be sold as part of a larger software package but
@@ -378,7 +393,7 @@ with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
-fonts, including any derivative works, can be bundled, embedded,
+fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
@@ -7,6 +7,7 @@ set(ROR_USE_CAELUM "TRUE" CACHE BOOL "use caelum sky")
set(ROR_USE_ANGELSCRIPT "TRUE" CACHE BOOL "use angel script")
set(ROR_USE_CURL "TRUE" CACHE BOOL "use curl, required for communication with online services")
set(ROR_USE_JSONCPP "TRUE" CACHE BOOL "use jsoncpp")
+set(ROR_USE_CRASHRPT "FALSE" CACHE BOOL "use crash report tool")
# some obsolete options:
@@ -168,8 +169,8 @@ endmacro(importLib)
if(ROR_USE_CRASHRPT)
set(CRASHRPT_INCLUDE_DIRS "${ROR_DEPENDENCIES_DIR}/includes/${ARCH_DIR}/CrashRpt" CACHE PATH "The CrashRpt include path to use")
- set(CRASHRPT_LIBRARY_DIRS "${ROR_DEPENDENCIES_DIR}/libs/${ARCH_DIR}/CrashRpt" CACHE PATH "The CrashRpt lib path to use")
- set(CRASHRPT_LIBRARIES "CrashRpt1300.lib" CACHE STRING "The CrashRpt lib to link against")
+ importLib(CrashRpt CrashRpt)
+ set(CRASHRPT_LIBRARIES "CrashRpt" CACHE STRING "The CrashRpt lib to link against")
endif(ROR_USE_CRASHRPT)
if(ROR_USE_ANGELSCRIPT)
@@ -321,6 +321,9 @@ if(WIN32)
if(ROR_USE_MOFILEREADER)
copy_lib_files_for_target(${BINNAME} MoFileReader)
endif()
+ if(ROR_USE_CRASHRPT)
+ copy_lib_files_for_target(${BINNAME} CrashRpt)
+ endif()
else()
copy_files_for_target("${BINNAME}" "${ROR_BINTOOL_DIR}/*")
endif()
@@ -443,6 +446,7 @@ setup_lib(PAGED)
setup_lib(CAELUM)
setup_lib(ANGELSCRIPT)
setup_lib(JSONCPP)
+setup_lib(CRASHRPT)
if(ROR_USE_ANGELSCRIPT)
# CLEAR_FPU_STACK prevents angelscript from breaking our physics engine
View
@@ -34,6 +34,91 @@
using namespace Ogre;
+#ifdef USE_CRASHRPT
+// see http://crashrpt.sourceforge.net/
+#include "crashrpt.h"
+
+// Define the crash callback
+int CALLBACK CrashCallback(CR_CRASH_CALLBACK_INFO* pInfo)
+{
+ // Return CR_CB_DODEFAULT to generate error report
+ return CR_CB_DODEFAULT;
+}
+
+void install_crashrpt()
+{
+ // Install CrashRpt support
+ CR_INSTALL_INFO info;
+ memset(&info, 0, sizeof(CR_INSTALL_INFO));
+ info.cb = sizeof(CR_INSTALL_INFO);
+ info.pszAppName = "Rigs of Rods";
+ info.pszAppVersion = ROR_VERSION_STRING;
+ info.pszEmailSubject = "Error Report for Rigs of Rods";
+ info.pszEmailTo = "error-report@rigsofrods.org";
+ info.pszUrl = "http://crashfix.rigsofrods.org/index.php/crashReport/uploadExternal";
+ info.uPriorities[CR_HTTP] = 1; // Use HTTP.
+ info.uPriorities[CR_SMTP] = CR_NEGATIVE_PRIORITY; // Not user SMTP.
+ info.uPriorities[CR_SMAPI] = CR_NEGATIVE_PRIORITY; // Not use Simple MAPI.
+ info.dwFlags = CR_INST_AUTO_THREAD_HANDLERS; // Install the per-thread exception handlers automatically
+ info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS; // Install all available exception handlers
+ info.dwFlags |= CR_INST_SHOW_ADDITIONAL_INFO_FIELDS; // Makes "Your E-mail" and "Describe what you were doing when the problem occurred" fields of Error Report dialog always visible.
+ info.pszPrivacyPolicyURL = "http://docs.rigsofrods.org/legal/crash-report-privacy-policy/"; // URL for the Privacy Policy link
+
+ crSetCrashCallback(CrashCallback, NULL);
+
+ int nInstResult = crInstall(&info);
+ if (nInstResult != 0)
+ {
+ // Something goes wrong!
+ TCHAR szErrorMsg[512];
+ szErrorMsg[0] = 0;
+
+ crGetLastErrorMsg(szErrorMsg, 512);
+ printf("%s\n", szErrorMsg);
+
+
+ ErrorUtils::ShowError(_L("Exception handling registration problem"), String(szErrorMsg));
+
+ assert(nInstResult == 0);
+ }
+
+ // logs
+ crAddFile2((RoR::App::GetSysLogsDir() + PATH_SLASH + "RoR.log").c_str(), "RoR.log", "Rigs of Rods Log", CR_AF_FILE_MUST_EXIST);
+ crAddFile2((RoR::App::GetSysLogsDir() + PATH_SLASH + "mygui.log").c_str(), "mygui.log", "Rigs of Rods GUI Log", CR_AF_FILE_MUST_EXIST);
+ crAddFile2((RoR::App::GetSysLogsDir() + PATH_SLASH + "configlog.txt").c_str(), "configlog.txt", "Rigs of Rods Configurator Log", CR_AF_FILE_MUST_EXIST);
+
+ // cache
+ crAddFile2((RoR::App::GetSysCacheDir() + PATH_SLASH + "mods.cache").c_str(), "mods.cache", "Rigs of Rods Cache File", CR_AF_FILE_MUST_EXIST);
+
+ // configs
+ crAddFile2((RoR::App::GetSysConfigDir() + PATH_SLASH + "ground_models.cfg").c_str(), "ground_models.cfg", "Rigs of Rods Ground Configuration", CR_AF_FILE_MUST_EXIST);
+ crAddFile2((RoR::App::GetSysConfigDir() + PATH_SLASH + "input.map").c_str(), "input.map", "Rigs of Rods Input Configuration", CR_AF_FILE_MUST_EXIST);
+ crAddFile2((RoR::App::GetSysConfigDir() + PATH_SLASH + "ogre.cfg").c_str(), "ogre.cfg", "Rigs of Rods Renderer Configuration", CR_AF_FILE_MUST_EXIST);
+ crAddFile2((RoR::App::GetSysConfigDir() + PATH_SLASH + "RoR.cfg").c_str(), "RoR.cfg", "Rigs of Rods Configuration", CR_AF_FILE_MUST_EXIST);
+
+ crAddProperty("Version", ROR_VERSION_STRING);
+ crAddProperty("protocol_version", RORNET_VERSION);
+ crAddProperty("build_date", __DATE__);
+ crAddProperty("build_time", __TIME__);
+
+ crAddProperty("System_GUID", SSETTING("GUID", "None").c_str());
+ crAddProperty("Multiplayer", RoR::App::GetActiveMpState() ? "1" : "0");
+
+ crAddScreenshot2(CR_AS_MAIN_WINDOW, 0);
+}
+
+void uninstall_crashrpt()
+{
+ crUninstall();
+}
+
+void test_crashrpt()
+{
+ //generate a null pointer exception.
+ crEmulateCrash(CR_SEH_EXCEPTION);
+}
+#endif
+
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@@ -151,6 +236,11 @@ int main(int argc, char *argv[])
return 0;
}
+#ifdef USE_CRASHRPT
+ install_crashrpt();
+ //test_crashrpt();
+#endif //USE_CRASHRPT
+
MainThread main_obj;
main_obj.Go();
}
@@ -163,6 +253,10 @@ int main(int argc, char *argv[])
ErrorUtils::ShowError(_L("An exception (std::runtime_error) has occured!"), e.what());
}
+#ifdef USE_CRASHRPT
+ uninstall_crashrpt();
+#endif //USE_CRASHRPT
+
return 0;
}

0 comments on commit 07d34bb

Please sign in to comment.