mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
Add @Daaaav's changes (full changelog below)
- remove more useless headerfiles - rename [level, name] to [area, roomname] - remove 10 repeats fallback - do not update_activity if it is the same value as last DISCORD_update - fix bug with DiscordCreate failure handling - rename (and invert) discordNotDetected to discordDetected
This commit is contained in:
parent
459437cbac
commit
7fcba8510e
5 changed files with 29 additions and 33 deletions
|
@ -3,7 +3,6 @@
|
||||||
#ifndef MAKEANDPLAY
|
#ifndef MAKEANDPLAY
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
@ -23,8 +22,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define DISCORD_CRASH_LIMIT 10
|
#define DISCORD_CLIENT_ID 1315544357532729447
|
||||||
#define DISCORD_CLIENT_ID 1315544357532729447 // TO TERRY/FLIBIT: You can create your own Discord instance at the Discord Developer Portal. This ID belongs to me, so just be aware that if my account was to get hacked, VVVVVV RPC would too. Use your own!
|
|
||||||
|
// TO TERRY/FLIBIT: You can create your own Discord instance at the Discord Developer Portal. This ID belongs to me, so just be aware that if my account was to get hacked, VVVVVV RPC would too. Use your own!
|
||||||
|
|
||||||
|
|
||||||
struct DISCORD_application {
|
struct DISCORD_application {
|
||||||
|
@ -34,8 +34,7 @@ struct DISCORD_application {
|
||||||
|
|
||||||
struct DiscordActivity activity;
|
struct DiscordActivity activity;
|
||||||
|
|
||||||
bool discordNotDetected = false;
|
bool discordDetected = false;
|
||||||
int discordCrashes = 0; // This is here to ensure we do not get stuck in a theoratical softlock of opening and crashing Discord instances.
|
|
||||||
|
|
||||||
static void* libHandle = NULL;
|
static void* libHandle = NULL;
|
||||||
|
|
||||||
|
@ -95,14 +94,14 @@ int32_t DISCORD_init(void)
|
||||||
params.client_id = DISCORD_CLIENT_ID;
|
params.client_id = DISCORD_CLIENT_ID;
|
||||||
params.flags = DiscordCreateFlags_NoRequireDiscord;
|
params.flags = DiscordCreateFlags_NoRequireDiscord;
|
||||||
|
|
||||||
if(!DiscordCreate(DISCORD_VERSION, ¶ms, &app.core))
|
if(DiscordCreate(DISCORD_VERSION, ¶ms, &app.core) != DiscordResult_Ok)
|
||||||
{
|
{
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(app.core == NULL)
|
if(app.core == NULL)
|
||||||
{
|
{
|
||||||
discordNotDetected = true;
|
discordDetected = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,41 +114,38 @@ int32_t DISCORD_init(void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DISCORD_REQUIRE(int x) {
|
bool DISCORD_REQUIRE(int x) {
|
||||||
if(discordNotDetected)
|
if(!discordDetected)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
|
||||||
if(discordCrashes > DISCORD_CRASH_LIMIT)
|
|
||||||
{
|
|
||||||
DISCORD_shutdown();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if(x != DiscordResult_Ok)
|
if(x != DiscordResult_Ok)
|
||||||
{
|
{
|
||||||
++discordCrashes;
|
return false;
|
||||||
DISCORD_shutdown();
|
|
||||||
DISCORD_init();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
discordCrashes = 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DISCORD_update(const char *level, const char *name)
|
void DISCORD_update(const char* area, const char* roomname)
|
||||||
{
|
{
|
||||||
if(discordCrashes > DISCORD_CRASH_LIMIT) {
|
if(app.core == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(app.activityMan == NULL)
|
if(app.activityMan == NULL)
|
||||||
{
|
{
|
||||||
app.activityMan = app.core->get_activity_manager(app.core);
|
app.activityMan = app.core->get_activity_manager(app.core);
|
||||||
}
|
}
|
||||||
SDL_strlcpy(activity.state, name, sizeof(activity.state));
|
if(activity.state == roomname || activity.assets.large_text == area)
|
||||||
|
{
|
||||||
|
DISCORD_REQUIRE(app.core->run_callbacks(app.core));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SDL_strlcpy(activity.state, roomname, sizeof(activity.state));
|
||||||
SDL_strlcpy(activity.assets.large_image, "vvvvvv", sizeof(activity.assets.large_image));
|
SDL_strlcpy(activity.assets.large_image, "vvvvvv", sizeof(activity.assets.large_image));
|
||||||
SDL_strlcpy(activity.assets.large_text, level, sizeof(activity.assets.large_text));
|
SDL_strlcpy(activity.assets.large_text, area, sizeof(activity.assets.large_text));
|
||||||
|
|
||||||
app.activityMan->update_activity(app.activityMan, &activity, NULL, NULL);
|
app.activityMan->update_activity(app.activityMan, &activity, NULL, NULL);
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@ void GOG_shutdown(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void GOG_update(const char *level, const char *name)
|
void GOG_update(const char* area, const char* roomname)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void GOG_unlockAchievement(const char *name)
|
void GOG_unlockAchievement(const char* name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#define DECLARE_BACKEND(name) \
|
#define DECLARE_BACKEND(name) \
|
||||||
int32_t name##_init(void); \
|
int32_t name##_init(void); \
|
||||||
void name##_shutdown(void); \
|
void name##_shutdown(void); \
|
||||||
void name##_update(const char *level, const char *name); \
|
void name##_update(const char *area, const char *roomname); \
|
||||||
void name##_unlockAchievement(const char *name);
|
void name##_unlockAchievement(const char *name);
|
||||||
#ifdef STEAM_NETWORK
|
#ifdef STEAM_NETWORK
|
||||||
DECLARE_BACKEND(STEAM)
|
DECLARE_BACKEND(STEAM)
|
||||||
|
@ -104,14 +104,14 @@ void NETWORK_shutdown(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void NETWORK_update(const char *level, const char *name)
|
void NETWORK_update(const char *area, const char *roomname)
|
||||||
{
|
{
|
||||||
#if NUM_BACKENDS > 0
|
#if NUM_BACKENDS > 0
|
||||||
int32_t i;
|
int32_t i;
|
||||||
for (i = 0; i < NUM_BACKENDS; i += 1)
|
for (i = 0; i < NUM_BACKENDS; i += 1)
|
||||||
if (backends[i].IsInit)
|
if (backends[i].IsInit)
|
||||||
{
|
{
|
||||||
backends[i].Update(level, name);
|
backends[i].Update(area, roomname);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ int32_t NETWORK_init(void);
|
||||||
|
|
||||||
void NETWORK_shutdown(void);
|
void NETWORK_shutdown(void);
|
||||||
|
|
||||||
void NETWORK_update(const char *level, const char *name);
|
void NETWORK_update(const char *area, const char *roomname);
|
||||||
|
|
||||||
void NETWORK_unlockAchievement(const char *name);
|
void NETWORK_unlockAchievement(const char *name);
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ void STEAM_shutdown(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void STEAM_update(const char *level, const char *name)
|
void STEAM_update(const char* area, const char* roomname)
|
||||||
{
|
{
|
||||||
if (!libHandle)
|
if (!libHandle)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue