-
-
Notifications
You must be signed in to change notification settings - Fork 38
[Feature]: Add on crash uploaded SourceMod forward #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
99b3cad
Squashed commit of the following:
caxanga334 f4d60b3
Update accelerator.inc
caxanga334 d0cb652
Fix: Missing forwards.cpp in AMBuilder
caxanga334 1a6223a
Refactor API
caxanga334 d06a0fd
Implement Requested Changes
caxanga334 68ba00f
Fix Error
caxanga334 e567441
Update Example Plugin
caxanga334 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,59 @@ | ||
| #include <array> | ||
| #include <string> | ||
| #include "extension.h" | ||
| #include "forwards.h" | ||
|
|
||
| static SourceMod::IForward* s_postuploadfoward = nullptr; | ||
|
|
||
| struct CrashPawnData | ||
| { | ||
| int index; | ||
| std::string response; | ||
| }; | ||
|
|
||
| static void OnCrashUploadedCallback(void* data) | ||
| { | ||
| CrashPawnData* crashdata = reinterpret_cast<CrashPawnData*>(data); | ||
|
|
||
| if (s_postuploadfoward) | ||
| { | ||
| s_postuploadfoward->PushCell(crashdata->index); | ||
| s_postuploadfoward->PushString(crashdata->response.c_str()); | ||
|
Kenzzer marked this conversation as resolved.
Outdated
|
||
| s_postuploadfoward->PushCell(static_cast<cell_t>(crashdata->response.size())); | ||
| s_postuploadfoward->Execute(nullptr); | ||
| } | ||
|
|
||
| delete crashdata; | ||
| } | ||
|
|
||
| void extforwards::Init() | ||
| { | ||
| std::array types = { | ||
| SourceMod::ParamType::Param_Cell, | ||
| SourceMod::ParamType::Param_String, | ||
| SourceMod::ParamType::Param_Cell, | ||
| }; | ||
|
|
||
| s_postuploadfoward = forwards->CreateForward("Accelerator_OnCrashUploaded", SourceMod::ExecType::ET_Ignore, 3, types.data()); | ||
| } | ||
|
|
||
| void extforwards::Shutdown() | ||
| { | ||
| if (s_postuploadfoward) | ||
| { | ||
| forwards->ReleaseForward(s_postuploadfoward); | ||
| s_postuploadfoward = nullptr; | ||
| } | ||
| } | ||
|
|
||
| void extforwards::CallForward(int crashIndex, const char* response) | ||
| { | ||
| CrashPawnData* data = new CrashPawnData; | ||
|
|
||
| data->index = crashIndex; | ||
| data->response.assign(response); | ||
|
|
||
| // Accelerator uploads from a secondary thread, calling a forward directly will crash | ||
| // this will call the forward from the main thread. | ||
| smutils->AddFrameAction(OnCrashUploadedCallback, reinterpret_cast<void*>(data)); | ||
| } | ||
This file contains hidden or 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,11 @@ | ||
| #ifndef _INCLUDE_FORWARDS_H_ | ||
| #define _INCLUDE_FORWARDS_H_ | ||
|
|
||
| namespace extforwards | ||
| { | ||
| void Init(); | ||
| void Shutdown(); | ||
| void CallForward(int crashIndex, const char* response); | ||
| } | ||
|
|
||
| #endif // !_INCLUDE_FORWARDS_H_ |
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
| /** | ||
| * Accelerator's SourcePawn include file | ||
| */ | ||
|
|
||
| #if defined _accelerator_included | ||
| #endinput | ||
| #endif | ||
| #define _accelerator_included | ||
|
|
||
|
|
||
| /** | ||
| * Called when a crash dump is uploaded. | ||
| * | ||
| * @param index Index of the crash. | ||
| * @param response HTTP response in plain text. | ||
| * @param responsesize HTTP response char buffer size. | ||
| */ | ||
| forward void Accelerator_OnCrashUploaded(int index, const char[] response, int responsesize); | ||
|
Kenzzer marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * Do not edit below this line! | ||
| */ | ||
| public Extension __ext_accelerator = | ||
| { | ||
| name = "accelerator", | ||
| file = "accelerator.ext", | ||
| #if defined AUTOLOAD_EXTENSIONS | ||
| autoload = 1, | ||
| #else | ||
| autoload = 0, | ||
| #endif | ||
| #if defined REQUIRE_EXTENSIONS | ||
| required = 1, | ||
| #else | ||
| required = 0, | ||
| #endif | ||
| }; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.