mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Copy over an ASCII version of Discord username if a username hasn't been set
This commit is contained in:
parent
5625505660
commit
f9695ca40c
1 changed files with 15 additions and 0 deletions
|
|
@ -1,14 +1,29 @@
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
#include "pc/debuglog.h"
|
#include "pc/debuglog.h"
|
||||||
|
#include "pc/configfile.h"
|
||||||
|
|
||||||
static void on_current_user_update(UNUSED void* data) {
|
static void on_current_user_update(UNUSED void* data) {
|
||||||
LOG_INFO("> on_current_user_update");
|
LOG_INFO("> on_current_user_update");
|
||||||
struct DiscordUser user;
|
struct DiscordUser user;
|
||||||
app.users->get_current_user(app.users, &user);
|
app.users->get_current_user(app.users, &user);
|
||||||
app.userId = user.id;
|
app.userId = user.id;
|
||||||
|
|
||||||
|
// copy over discord username if we haven't set one yet
|
||||||
|
if (configPlayerName[0] == '\0' && strlen(user.username) > 0) {
|
||||||
|
char* cname = configPlayerName;
|
||||||
|
char* dname = user.username;
|
||||||
|
for (int i = 0; i < MAX_PLAYER_STRING - 1; i++) {
|
||||||
|
if (*dname >= '!' && *dname <= '~') {
|
||||||
|
*cname = *dname;
|
||||||
|
cname++;
|
||||||
|
}
|
||||||
|
dname++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IDiscordUserEvents* discord_user_initialize(void) {
|
struct IDiscordUserEvents* discord_user_initialize(void) {
|
||||||
|
LOG_INFO("> discord_user_intitialize");
|
||||||
static struct IDiscordUserEvents events = { 0 };
|
static struct IDiscordUserEvents events = { 0 };
|
||||||
events.on_current_user_update = on_current_user_update;
|
events.on_current_user_update = on_current_user_update;
|
||||||
return &events;
|
return &events;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue