Skip to content

Commit 8c45fda

Browse files
committed
Merge branch 'dev'
2 parents 897e1bd + cf39979 commit 8c45fda

File tree

41 files changed

+809
-788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+809
-788
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center"><img src="https://raw.githubusercontent.com/JujuAdams/Snitch/master/LOGO.png" style="display:block; margin:auto; width:300px"></p>
22

3-
<h1 align="center">Snitch 3.1.0</h1>
3+
<h1 align="center">Snitch 4.0.0</h1>
44

55
<p align="center">Logging and crash handling system for GameMaker Studio 2022 LTS by <b>@jujuadams</b></p>
66

Snitch.yyp

+15-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__SnitchError("__SnitchController instance has been destroyed\nPlease ensure that this instance always exists");
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var _id = string(async_load[? "id"]);
2+
if (variable_struct_exists(__SnitchState().__HTTPRequests, _id))
3+
{
4+
//Pass the response into the request's response handler
5+
__SnitchState().__HTTPRequests[$ _id].__HTTPResponse(async_load[? "http_status"], async_load[? "status"]);
6+
7+
//Output extra details if there was a failure to submit a request
8+
if (SNITCH_OUTPUT_HTTP_FAILURE_DETAILS && (async_load[? "http_status"] != 200) && (async_load[? "http_status"] != 204))
9+
{
10+
var _result = async_load[? "result"];
11+
try
12+
{
13+
var _json = json_parse(_result);
14+
__SnitchTrace("Result was:\n", __SnitchSNAPtoJSON(_json, true, true));
15+
}
16+
catch(_error)
17+
{
18+
__SnitchTrace("Result was: \"", _result, "\"");
19+
}
20+
}
21+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
var _snitchState = __SnitchState();
2+
3+
switch(async_load[? "type"])
4+
{
5+
case network_type_disconnect:
6+
__SnitchTrace("TCP connection lost, retrying");
7+
_snitchState.__NetworkConnectionAttempts = 0;
8+
_snitchState.__NetworkConnected = false;
9+
_snitchState.__NetworkAbandoned = false;
10+
__SnitchAttemptTCPConnection();
11+
break;
12+
13+
case network_type_non_blocking_connect:
14+
if (async_load[? "succeeded"])
15+
{
16+
__SnitchTrace("TCP connection established");
17+
_snitchState.__NetworkConnected = true;
18+
_snitchState.__NetworkAbandoned = false;
19+
}
20+
else
21+
{
22+
_snitchState.__NetworkConnectionAttempts++;
23+
if (_snitchState.__NetworkConnectionAttempts >= SNITCH_NETWORK_CONNECTION_ATTEMPTS)
24+
{
25+
__SnitchTrace("TCP connection failed to establish despite ", _snitchState.__NetworkConnectionAttempts, " attempts, giving up");
26+
_snitchState.__NetworkConnected = false;
27+
_snitchState.__NetworkAbandoned = true;
28+
}
29+
else
30+
{
31+
__SnitchTrace("TCP connection failed to establish, retrying");
32+
__SnitchAttemptTCPConnection();
33+
}
34+
}
35+
break;
36+
}

objects/__SnitchController/Step_1.gml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
var _snitchState = __SnitchState();
2+
3+
_snitchState.__Frames++;
4+
5+
if (!os_is_paused() && window_has_focus())
6+
{
7+
_snitchState.__FocusFrames++;
8+
_snitchState.__FocusTime += delta_time/1000;
9+
}
10+
11+
if (SNITCH_NETWORK_MODE == 2)
12+
{
13+
if (_snitchState.__NetworkConnected)
14+
{
15+
//Churn through the pending messages and clear them out
16+
repeat(ceil(sqrt(array_length(_snitchState.__NetworkPendingMessages))))
17+
{
18+
__SnitchSendStringToNetwork(_snitchState.__NetworkPendingMessages[0]);
19+
array_delete(_snitchState.__NetworkPendingMessages, 0, 1);
20+
}
21+
}
22+
}
23+
24+
if (_snitchState.__RequestBackupFailures < SNITCH_REQUEST_BACKUP_RESEND_MAX_FAILURES)
25+
{
26+
if (current_time - _snitchState.__RequestBackupResendTime > SNITCH_REQUEST_BACKUP_RESEND_DELAY)
27+
{
28+
var _backupCount = array_length(_snitchState.__RequestBackupOrder);
29+
if (_backupCount > 0)
30+
{
31+
//Step round the request backup array
32+
_snitchState.__RequestBackupResendIndex = (_snitchState.__RequestBackupResendIndex + 1) mod _backupCount;
33+
34+
//Pull out a backup...
35+
var _uuid = _snitchState.__RequestBackupOrder[_snitchState.__RequestBackupResendIndex];
36+
with(_snitchState.__RequestBackups[$ _uuid])
37+
{
38+
//...and if we're not waiting for a response for this particular request, resend it
39+
if (asyncID < 0)
40+
{
41+
if (SNITCH_REQUEST_BACKUP_OUTPUT_ATTEMPT) __SnitchTrace("Trying to resend event ", _uuid);
42+
43+
switch(SNITCH_SERVICE_MODE)
44+
{
45+
case 1: __SnitchSentryHTTPRequest(self); break;
46+
case 2: __SnitchGameAnalyticsHTTPRequest(self); break;
47+
case 3: __SnitchBugsnagHTTPRequest(self); break;
48+
}
49+
50+
_snitchState.__RequestBackupResendTime = current_time;
51+
}
52+
}
53+
}
54+
}
55+
}
56+
else
57+
{
58+
if (current_time - _snitchState.__RequestBackupResendTime > SNITCH_REQUEST_BACKUP_RESEND_FAILURE_TIMEOUT)
59+
{
60+
_snitchState.__RequestBackupFailures = 0;
61+
__SnitchTrace("Retrying backup resending");
62+
}
63+
}

objects/__SnitchController/__SnitchController.yy

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

objects/oTest/Draw_0.gml

+6-5
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@ if (is_struct(crashDump))
2121

2222
try
2323
{
24-
_string += "message = \"" + string(crashDump.message) + "\"\n";
24+
var _exception = crashDump.exception
25+
_string += "message = \"" + string(_exception.message) + "\"\n";
2526
_string += "\n";
26-
_string += "longMessage = \"" + string(crashDump.longMessage) + "\"\n";
27+
_string += "longMessage = \"" + string(_exception.longMessage) + "\"\n";
2728
_string += "\n";
28-
_string += "script = \"" + string(crashDump.script) + "\"\n";
29+
_string += "script = \"" + string(_exception.script) + "\"\n";
2930
_string += "\n";
30-
_string += "line = " + string(crashDump.line) + "\n";
31+
_string += "line = " + string(_exception.line) + "\n";
3132
_string += "\n";
32-
_string += "stacktrace = " + string(crashDump.stacktrace) + "\n";
33+
_string += "stacktrace = " + string(_exception.stacktrace) + "\n";
3334
_string += "\n";
3435
}
3536
catch(_error)

options/windows/options_windows.yy

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/SnitchCrashDumpCollect/SnitchCrashDumpCollect.gml

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
function SnitchCrashDumpCollect()
77
{
8-
__SnitchInit();
9-
108
var _struct = undefined;
119

1210
if ((SNITCH_CRASH_DUMP_FILENAME != "") && file_exists(SNITCH_CRASH_DUMP_FILENAME))

scripts/SnitchCrashDumpDelete/SnitchCrashDumpDelete.gml

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22

33
function SnitchCrashDumpDelete()
44
{
5-
__SnitchInit();
6-
75
if ((SNITCH_CRASH_DUMP_FILENAME != "") && file_exists(SNITCH_CRASH_DUMP_FILENAME)) file_delete(SNITCH_CRASH_DUMP_FILENAME);
86
}

scripts/SnitchGenerateUUID4String/SnitchGenerateUUID4String.gml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function SnitchGenerateUUID4String(_hyphenate = false)
1515

1616
////Set up the XORShift32 starting seed
1717
////Can throw in a randomize() / random() call here too if you'd like but 1) that might mess up other stuff? 2) feels unnecessary
18-
//global.__snitchXORShift32State = floor(1000000*date_current_datetime() + display_mouse_get_x() + display_get_width()*display_mouse_get_y());
18+
//__SnitchState().__XORShift32State = floor(1000000*date_current_datetime() + display_mouse_get_x() + display_get_width()*display_mouse_get_y());
1919

2020
//Basic XORShift32, nothing fancy
2121
function __SnitchXORShift32Random(_value)

scripts/SnitchHTTPAsyncEvent/SnitchHTTPAsyncEvent.gml

-39
This file was deleted.

scripts/SnitchLogGet/SnitchLogGet.gml

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
function SnitchLogGet()
55
{
6-
__SnitchInit();
7-
86
if (!SNITCH_LOG_PERMITTED) return false;
9-
10-
return global.__snitchLogToFileEnabled;
7+
return __SnitchState().__LogToFileEnabled;
118
}

0 commit comments

Comments
 (0)