Skip to content

Commit

Permalink
Fixed this shit segmentation faulting when discord isnt running.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogFeelings committed Dec 5, 2021
1 parent 790951b commit c4e6500
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions Blitzcord.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>
#include <stdlib.h>
#include <chrono>
#include <limits>

#define uint64 unsigned long long
#define uint32 unsigned int
Expand Down
24 changes: 23 additions & 1 deletion Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,90 +11,107 @@ BLITZ3D(void) BlitzcordCreateCore(cchar id)
int upperID = longUpper(convertedLong);
int lowerID = longLower(convertedLong);

auto result = discord::Core::Create(mergeLong(upperID, lowerID), DiscordCreateFlags_NoRequireDiscord, &core);
discord::Result result = discord::Core::Create(mergeLong(upperID, lowerID), DiscordCreateFlags_NoRequireDiscord, &core);

if (core == nullptr) return;
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
}

BLITZ3D(void) BlitzcordRunCallbacks()
{
if (core == nullptr) return;
::core->RunCallbacks();
}

//ACTIVITY FUNCTIONS
//------------------
BLITZ3D(void) BlitzcordSetActivityState(cchar state)
{
if (core == nullptr) return;
activity.SetState(state);
}

BLITZ3D(void) BlitzcordSetActivityDetails(cchar details)
{
if (core == nullptr) return;
activity.SetDetails(details);
}

BLITZ3D(void) BlitzcordSetActivityType(int type)
{
if (core == nullptr) return;
activity.SetType((discord::ActivityType)type);
}

BLITZ3D(void) BlitzcordClearActivity()
{
if (core == nullptr) return;
core->ActivityManager().ClearActivity([](discord::Result result) {});
}

BLITZ3D(void) BlitzcordUpdateActivity()
{
if (core == nullptr) return;
core->ActivityManager().UpdateActivity(activity, [](discord::Result result) {});
}

//SMALL IMAGE FUNCTIONS
//---------------------
BLITZ3D(void) BlitzcordSetSmallImage(cchar image)
{
if (core == nullptr) return;
activity.GetAssets().SetSmallImage(image);
}

BLITZ3D(void) BlitzcordSetSmallText(cchar text)
{
if (core == nullptr) return;
activity.GetAssets().SetSmallText(text);
}

BLITZ3D(cchar) BlitzcordGetSmallImage()
{
if (core == nullptr) return "";
return activity.GetAssets().GetSmallImage();
}

BLITZ3D(cchar) BlitzcordGetSmallText()
{
if (core == nullptr) return "";
return activity.GetAssets().GetSmallText();
}

//LARGE IMAGE FUNCTIONS
//---------------------
BLITZ3D(void) BlitzcordSetLargeImage(cchar image)
{
if (core == nullptr) return;
activity.GetAssets().SetLargeImage(image);
}

BLITZ3D(void) BlitzcordSetLargeText(cchar text)
{
if (core == nullptr) return;
activity.GetAssets().SetLargeText(text);
}

BLITZ3D(cchar) BlitzcordGetLargeImage()
{
if (core == nullptr) return "";
return activity.GetAssets().GetLargeImage();
}

BLITZ3D(cchar) BlitzcordGetLargeText()
{
if (core == nullptr) return "";
return activity.GetAssets().GetLargeText();
}

//TIMESTAMP FUNCTIONS
//-------------------
BLITZ3D(void) BlitzcordSetTimestampStart(cchar timestamp)
{
if (core == nullptr) return;
long long convertedLong = atoll(timestamp);
int upperLong = longUpper(convertedLong);
int lowerLong = longLower(convertedLong);
Expand All @@ -104,6 +121,7 @@ BLITZ3D(void) BlitzcordSetTimestampStart(cchar timestamp)

BLITZ3D(void) BlitzcordSetTimestampEnd(cchar timestamp)
{
if (core == nullptr) return;
long long convertedLong = atoll(timestamp);
int upperLong = longUpper(convertedLong);
int lowerLong = longLower(convertedLong);
Expand All @@ -113,21 +131,25 @@ BLITZ3D(void) BlitzcordSetTimestampEnd(cchar timestamp)

BLITZ3D(int) BlitzcordGetTimestampStartUpper()
{
if (core == nullptr) return INT_MAX;
return longUpper(activity.GetTimestamps().GetStart());
}

BLITZ3D(int) BlitzcordGetTimestampStartLower()
{
if (core == nullptr) return INT_MAX;
return longLower(activity.GetTimestamps().GetStart());
}

BLITZ3D(int) BlitzcordGetTimestampEndUpper()
{
if (core == nullptr) return INT_MAX;
return longUpper(activity.GetTimestamps().GetEnd());
}

BLITZ3D(int) BlitzcordGetTimestampEndLower()
{
if (core == nullptr) return INT_MAX;
return longLower(activity.GetTimestamps().GetEnd());
}

Expand Down

0 comments on commit c4e6500

Please sign in to comment.