-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 060e160
Showing
42 changed files
with
2,721 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2024 The Aridity Team | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# sentry-source-engine | ||
This repository contains the files needed to implement Sentry to the Source engine. This code was published in hope that this could help sourcemodders track the player's session incase of crashing. | ||
|
||
## How do I add this into my sourcemod? | ||
Here's the list of things you require before you continue on this tutorial: | ||
- A existing Sentry project (see https://docs.sentry.io/product/sentry-basics/integrate-frontend/create-new-project on how to create a project) | ||
- Source SDK 2013 code (duh) | ||
- Visual Studio Community/Professional 2013 (you can download it here: https://archive.org/details/en_visual_studio_community_2013_with_update_5_x86_dvd_6816332) | ||
|
||
***WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*** \ | ||
This implemention was only tested in Source SDK 2013 CE. Meaning that a later version of Visual Studio and buildtools was used in implementing Sentry. For the love of god, just please DM me on Discord (jeff.hm_.) if it actually works on the original codebase | ||
|
||
--- | ||
|
||
Anyways, back to the tutorial. \ | ||
|
||
### STEP 1 | ||
First, you need to download the sentry-source-engine which is this repository you're on right now. You can download it as a archive or clone it using Git. | ||
|
||
### STEP 2 | ||
Copy the contents of the `src` directory to your mod's source code one. \ | ||
***You can place the `sentry_native` folder anywhere in the source code you want but the Sentry manager code (rw_sentry_manager.cpp & rw_sentry_manager.h) needs to be placed on the `src/game/shared` folder!*** | ||
|
||
### STEP 3 | ||
Edit your mod's client and server VPC script (client_hl2mp.vpc, server_hl2mp.vpc, etc.) \ | ||
On the client side, add the path to your sentry_native's `include` folder as a additional include directory. | ||
For example: | ||
 | ||
<br/> | ||
<br/> | ||
Now on the `Project` part, add the path to your sentry_native's `sentry.lib` file as a Link Library. | ||
For example: | ||
 \ | ||
|
||
Do the same for the server side. \ | ||
 | ||
|
||
(there's no need to do this as you can add additional include directories and libraries through Visual Studio itself but i'm too lazy to screenshot it) | ||
|
||
### STEP 4 | ||
Now, run the `creategameprojects.bat` script. This will create a Visual Studio solution file to build your mod. | ||
 \ | ||
Once the solution file has been created, open it with Visual Studio 2013. | ||
By default, the solution file name is `games.sln`. \ | ||
|
||
### STEP 5 | ||
Once you have opened the solution, there is one thing to do before compiling. \ | ||
First, right click the solution and then click `Properties`. \ | ||
 \ | ||
<br/> | ||
<br/> | ||
Navigate to the `Configuration Properties` and set the `Configuration` to `Release`. \ | ||
 \ | ||
 \ | ||
Once you did that, click on `OK` at the bottom of the window. \ | ||
<br/> | ||
<br/> | ||
Now, time to add the Sentry manager code. \ | ||
Navigate to any project, right-click the `Source Files` folder and click on `Add`. \ | ||
 \ | ||
Click on `Existing Item`. \ | ||
 \ | ||
This dialog will appear. Navigate to the `shared` folder (located in `src/game/shared`). \ | ||
 \ | ||
|
||
Now, find and select both `rw_sentry_manager.cpp` and `rw_sentry_manager.h` files then click on `Add`. | ||
 | ||
|
||
### STEP 6 | ||
Once you have both of the source files added, let's edit something on `rw_sentry_manager.cpp`. \ | ||
Go to around line 32 and edit the URL to your Sentry project's DSN link (see https://docs.sentry.io/concepts/key-terms/dsn-explainer/#where-to-find-your-dsn on where to get your project's DSN link). | ||
 \ | ||
Now, on to the main part. \ | ||
Open up `cdll_client_int.cpp` (it's located in your Client project)\ | ||
After the `#ifdef` for `WORKSHOP_IMPORT_ENABLED`, add `#include "rw_sentry_manager.h"` \ | ||
 | ||
|
||
Navigate to `CHLClient::Init` and add `RWSentryMgr()->Init();` after an another `#ifdef` for `WORKSHOP_IMPORT_ENABLED` \ | ||
It should look something like this: \ | ||
 | ||
|
||
Navigate to `CHLClient::Shutdown` and add `RWSentryMgr()->Shutdown();` after an yet another `#ifdef` for `WORKSHOP_IMPORT_ENABLED` \ | ||
It should look something like this: \ | ||
 | ||
|
||
On to the server-side. | ||
|
||
Open up `gameinterface.cpp` (it's located in your Server project)\ | ||
After the `#if defined()` for `REPLAY_ENABLED`, add `#include "rw_sentry_manager.h"` \ | ||
 | ||
|
||
Navigate to `CServerGameDll::DllInit` and add `RWSentryMgr()->Init();` after the `factorylist_t` bullshit \ | ||
It should look something like this: \ | ||
 | ||
|
||
Navigate to `CServerGameDll::DllShutdown` and add `RWSentryMgr()->Shutdown();` after the Steam API context shuts down \ | ||
It should look something like this: \ | ||
 | ||
|
||
Now, build your mod's code! \ | ||
 | ||
|
||
### STEP 7 | ||
Once it's finished building, navigate to the directory where you putted the `sentry_native` folder earlier and copy all the contents of `sentry_native`'s `bin` folder to your mod's `bin` folder (the `.pdb` files will be useful when debugging). \ | ||
 | ||
|
||
Your mod's `bin` folder should look like this: \ | ||
 | ||
|
||
Now, run your mod! \ | ||
If you see those log messages with `[ Sentry ] -` at the beginning in your developer console \ | ||
 \ | ||
and `crashpad_handler.exe` running alongside of `hl2.exe`, that means Sentry is working! \ | ||
 | ||
|
||
--- | ||
|
||
There you go! That's how you implement Sentry into your Source 2013 mod! |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
//=================== Copyright (c) 2024 The Aridity Team, all rights reserved. ===================// | ||
// | ||
// Purpose: Sentry integration | ||
// | ||
//=================================================================================================// | ||
|
||
#include "cbase.h" | ||
#pragma warning ( disable : 4005 ) | ||
#pragma warning ( disable : 4700 ) | ||
#include "sentry.h" | ||
#include "rw_sentry_manager.h" | ||
#include "string" | ||
|
||
CRWSentryMgr* g_SentryMgr = NULL; | ||
CRWSentryMgr* RWSentryMgr() | ||
{ | ||
return g_SentryMgr; | ||
} | ||
|
||
CRWSentryMgr::CRWSentryMgr() | ||
{ | ||
dsnLink = NULL; // unused | ||
} | ||
CRWSentryMgr::~CRWSentryMgr() | ||
{ | ||
delete dsnLink; | ||
} | ||
|
||
void CRWSentryMgr::Init() | ||
{ | ||
sentry_options_t* options = sentry_options_new(); | ||
sentry_options_set_dsn(options, "https://3e8ac4469aa6b58738c923d872796ac2@o4507485361668096.ingest.de.sentry.io/4508200806973520"); | ||
|
||
sentry_value_t event = sentry_value_new_event(); | ||
|
||
#ifdef GAME_DLL | ||
char gamePath[256]; | ||
engine->GetGameDir(gamePath, 256); | ||
Q_StripTrailingSlash(gamePath); | ||
|
||
std::string sGamePath = gamePath; | ||
std::string sHandlerPath = sGamePath.append("/bin/crashpad_handler.exe"); | ||
std::string sDbPath = sGamePath.append(".sentry-native"); | ||
|
||
const char *handlerPath = sHandlerPath.c_str(); | ||
const char* dbPath = sDbPath.c_str(); | ||
|
||
sentry_options_set_handler_path(options, handlerPath); | ||
sentry_options_set_database_path(options, dbPath); | ||
|
||
sentry_value_t exc = sentry_value_new_exception("Exception/Crash", "An exception has been thrown - server"); | ||
#else | ||
std::string sGamePath = engine->GetGameDirectory(); | ||
std::string sHandlerPath = sGamePath.append("/bin/crashpad_handler.exe"); | ||
std::string sDbPath = sGamePath.append(".sentry-native"); | ||
|
||
const char* handlerPath = sHandlerPath.c_str(); | ||
const char* dbPath = sDbPath.c_str(); | ||
|
||
sentry_options_set_handler_path(options, handlerPath); | ||
sentry_options_set_database_path(options, dbPath); | ||
|
||
sentry_value_t exc = sentry_value_new_exception("Exception/Crash", "An exception has been thrown - client"); | ||
#endif | ||
sentry_options_set_release(options, "[email protected]"); | ||
sentry_options_set_debug(options, 1); | ||
sentry_options_set_environment(options, "production"); | ||
|
||
sentry_value_set_stacktrace(exc, NULL, 0); | ||
sentry_event_add_exception(event, exc); | ||
|
||
sentry_capture_event(event); | ||
sentry_init(options); | ||
|
||
#ifdef CLIENT_DLL | ||
ConColorMsg(Color(54, 45, 89, 255), "[ Sentry ] Sentry initialized - client\n"); | ||
#else | ||
ConColorMsg(Color(54, 45, 89, 255), "[ Sentry ] Sentry initialized - server\n"); | ||
#endif | ||
} | ||
|
||
void CRWSentryMgr::Shutdown() | ||
{ | ||
sentry_shutdown(); | ||
} | ||
|
||
// logging | ||
void CRWSentryMgr::SentryLog(char* message) | ||
{ | ||
ConMsg(message); // log through the app output also | ||
sentry_capture_event(sentry_value_new_message_event( | ||
/* level */ SENTRY_LEVEL_INFO, | ||
/* logger */ "CRWSentryMgr", | ||
/* message */ message | ||
)); | ||
} | ||
void CRWSentryMgr::SentryWarn(char* message) | ||
{ | ||
ConMsg(message); // log through the app output also | ||
sentry_capture_event(sentry_value_new_message_event( | ||
/* level */ SENTRY_LEVEL_WARNING, | ||
/* logger */ "CRWSentryMgr", | ||
/* message */ message | ||
)); | ||
} | ||
void CRWSentryMgr::SentryError(char* message) | ||
{ | ||
ConMsg(message); // log through the app output also | ||
sentry_capture_event(sentry_value_new_message_event( | ||
/* level */ SENTRY_LEVEL_ERROR, | ||
/* logger */ "CRWSentryMgr", | ||
/* message */ message | ||
)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//=================== Copyright (c) 2024 The Aridity Team, all rights reserved. ===================// | ||
// | ||
// Purpose: Sentry integration | ||
// | ||
//=================================================================================================// | ||
|
||
#ifndef RW_SENTRY_MGR_H | ||
#define RW_SENTRY_MGR_H | ||
#ifdef _WIN32 | ||
#pragma once | ||
#endif | ||
|
||
#pragma warning ( disable : 4005 ) | ||
|
||
class CRWSentryMgr | ||
{ | ||
DECLARE_CLASS_NOBASE(CRWSentryMgr); | ||
|
||
public: | ||
CRWSentryMgr(); | ||
~CRWSentryMgr(); | ||
|
||
void Init(); | ||
void Shutdown(); | ||
|
||
void SentryLog(char* message); | ||
void SentryWarn(char* message); | ||
void SentryError(char* message); | ||
|
||
private: | ||
char* dsnLink; | ||
}; | ||
|
||
extern CRWSentryMgr* RWSentryMgr(); | ||
|
||
#endif // !RW_SENTRY_MGR_H | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.