mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-05 15:11:16 +00:00
Made discord/socket use the right format types on Linux vs Windows
This commit is contained in:
parent
f0ad3dd7d0
commit
4c4b2b826c
7 changed files with 21 additions and 16 deletions
|
@ -15,7 +15,7 @@ static void on_activity_update_callback(UNUSED void* data, enum EDiscordResult r
|
|||
}
|
||||
|
||||
static void on_activity_join_callback(UNUSED void* data, enum EDiscordResult result, struct DiscordLobby* lobby) {
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_activity_join_callback returned %d, lobby %ld, owner %ld", result, lobby->id, lobby->owner_id);
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_activity_join_callback returned %d, lobby " DISCORD_ID_FORMAT ", owner " DISCORD_ID_FORMAT, result, lobby->id, lobby->owner_id);
|
||||
DISCORD_REQUIRE(result);
|
||||
if (gNetworkType != NT_NONE) {
|
||||
LOGFILE_ERROR(LFT_DISCORD, "Joined lobby when already connected somewhere!");
|
||||
|
@ -25,7 +25,7 @@ static void on_activity_join_callback(UNUSED void* data, enum EDiscordResult res
|
|||
network_init(NT_CLIENT);
|
||||
|
||||
gCurActivity.type = DiscordActivityType_Playing;
|
||||
snprintf(gCurActivity.party.id, 128, "%ld", lobby->id);
|
||||
snprintf(gCurActivity.party.id, 128, DISCORD_ID_FORMAT, lobby->id);
|
||||
gCurActivity.party.size.current_size = 2;
|
||||
gCurActivity.party.size.max_size = lobby->capacity;
|
||||
|
||||
|
@ -57,7 +57,7 @@ static void on_activity_join_request_callback(UNUSED void* data, enum EDiscordRe
|
|||
}
|
||||
|
||||
static void on_activity_join_request(UNUSED void* data, struct DiscordUser* user) {
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_activity_join_request from %ld", user->id);
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_activity_join_request from " DISCORD_ID_FORMAT, user->id);
|
||||
//app.activities->send_request_reply(app.activities, user->id, DiscordActivityJoinRequestReply_Yes, NULL, on_activity_join_request_callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
#include "discord_game_sdk.h"
|
||||
#pragma pack(pop)
|
||||
#ifdef _WIN32
|
||||
#define DISCORD_ID_FORMAT "%lld"
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#define DISCORD_ID_FORMAT "%ld"
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
|
|
@ -48,14 +48,14 @@ void ns_discord_save_id(u8 localId, s64 networkId) {
|
|||
assert(localId > 0);
|
||||
assert(localId < MAX_PLAYERS);
|
||||
gNetworkUserIds[localId] = (networkId == 0) ? gNetworkUserIds[0] : networkId;
|
||||
LOGFILE_INFO(LFT_DISCORD, "saved user id %d == %ld", localId, gNetworkUserIds[localId]);
|
||||
LOGFILE_INFO(LFT_DISCORD, "saved user id %d == " DISCORD_ID_FORMAT, localId, gNetworkUserIds[localId]);
|
||||
}
|
||||
|
||||
void ns_discord_clear_id(u8 localId) {
|
||||
if (localId == 0) { return; }
|
||||
assert(localId < MAX_PLAYERS);
|
||||
gNetworkUserIds[localId] = 0;
|
||||
LOGFILE_INFO(LFT_DISCORD, "cleared user id %d == %ld", localId, gNetworkUserIds[localId]);
|
||||
LOGFILE_INFO(LFT_DISCORD, "cleared user id %d == " DISCORD_ID_FORMAT, localId, gNetworkUserIds[localId]);
|
||||
}
|
||||
|
||||
void discord_network_init(int64_t lobbyId) {
|
||||
|
@ -68,5 +68,5 @@ void discord_network_shutdown(void) {
|
|||
app.lobbies->flush_network(app.lobbies);
|
||||
if (gCurLobbyId == 0) { return; }
|
||||
app.lobbies->disconnect_network(app.lobbies, gCurLobbyId);
|
||||
LOGFILE_INFO(LFT_DISCORD, "shutdown network, lobby = %ld", gCurLobbyId);
|
||||
LOGFILE_INFO(LFT_DISCORD, "shutdown network, lobby = " DISCORD_ID_FORMAT, gCurLobbyId);
|
||||
}
|
|
@ -35,20 +35,20 @@ static void on_lobby_create_callback(UNUSED void* data, enum EDiscordResult resu
|
|||
}
|
||||
|
||||
DISCORD_REQUIRE(result);
|
||||
LOGFILE_INFO(LFT_DISCORD, "Lobby id: %ld", lobby->id);
|
||||
LOGFILE_INFO(LFT_DISCORD, "Lobby id: " DISCORD_ID_FORMAT, lobby->id);
|
||||
LOGFILE_INFO(LFT_DISCORD, "Lobby type: %u", lobby->type);
|
||||
LOGFILE_INFO(LFT_DISCORD, "Lobby owner id: %ld", lobby->owner_id);
|
||||
LOGFILE_INFO(LFT_DISCORD, "Lobby owner id: " DISCORD_ID_FORMAT, lobby->owner_id);
|
||||
LOGFILE_INFO(LFT_DISCORD, "Lobby secret: %s", lobby->secret);
|
||||
LOGFILE_INFO(LFT_DISCORD, "Lobby capacity: %u", lobby->capacity);
|
||||
LOGFILE_INFO(LFT_DISCORD, "Lobby locked: %d", lobby->locked);
|
||||
|
||||
gCurActivity.type = DiscordActivityType_Playing;
|
||||
snprintf(gCurActivity.party.id, 128, "%ld", lobby->id);
|
||||
snprintf(gCurActivity.party.id, 128, DISCORD_ID_FORMAT, lobby->id);
|
||||
gCurActivity.party.size.current_size = 1;
|
||||
gCurActivity.party.size.max_size = MAX_PLAYERS;
|
||||
|
||||
char secretJoin[128] = "";
|
||||
snprintf(secretJoin, 128, "%ld:%s", lobby->id, lobby->secret);
|
||||
snprintf(secretJoin, 128, DISCORD_ID_FORMAT ":%s", lobby->id, lobby->secret);
|
||||
strcpy(gCurActivity.secrets.join, secretJoin);
|
||||
|
||||
isHosting = true;
|
||||
|
@ -59,21 +59,21 @@ static void on_lobby_create_callback(UNUSED void* data, enum EDiscordResult resu
|
|||
}
|
||||
|
||||
static void on_lobby_update(UNUSED void* data, int64_t lobbyId) {
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_lobby_update id: %ld", lobbyId);
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_lobby_update id: " DISCORD_ID_FORMAT, lobbyId);
|
||||
}
|
||||
|
||||
static void on_member_connect(UNUSED void* data, int64_t lobbyId, int64_t userId) {
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_member_connect lobby: %ld, user: %ld", lobbyId, userId);
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_member_connect lobby: " DISCORD_ID_FORMAT ", user: " DISCORD_ID_FORMAT, lobbyId, userId);
|
||||
gCurActivity.party.size.current_size++;
|
||||
discord_activity_update(true);
|
||||
}
|
||||
|
||||
static void on_member_update(UNUSED void* data, int64_t lobbyId, int64_t userId) {
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_member_update lobby: %ld, user: %ld", lobbyId, userId);
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_member_update lobby: " DISCORD_ID_FORMAT ", user: " DISCORD_ID_FORMAT, lobbyId, userId);
|
||||
}
|
||||
|
||||
static void on_member_disconnect(UNUSED void* data, int64_t lobbyId, int64_t userId) {
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_member_disconnect lobby: %ld, user: %ld", lobbyId, userId);
|
||||
LOGFILE_INFO(LFT_DISCORD, "> on_member_disconnect lobby: " DISCORD_ID_FORMAT ", user: " DISCORD_ID_FORMAT, lobbyId, userId);
|
||||
u8 localIndex = discord_user_id_to_local_index(userId);
|
||||
if (localIndex != UNKNOWN_LOCAL_INDEX && gNetworkPlayers[localIndex].connected) {
|
||||
network_player_disconnected(gNetworkPlayers[localIndex].globalIndex);
|
||||
|
@ -108,7 +108,7 @@ void discord_lobby_leave(void) {
|
|||
app.lobbies->disconnect_lobby(app.lobbies, gCurLobbyId, NULL, on_lobby_leave_callback);
|
||||
}
|
||||
|
||||
LOGFILE_INFO(LFT_DISCORD, "left lobby %ld", gCurLobbyId);
|
||||
LOGFILE_INFO(LFT_DISCORD, "left lobby " DISCORD_ID_FORMAT, gCurLobbyId);
|
||||
|
||||
isHosting = false;
|
||||
gCurLobbyId = 0;
|
||||
|
|
|
@ -36,7 +36,7 @@ static int socket_send(SOCKET socket, struct sockaddr_in* addr, u8* buffer, u16
|
|||
static int socket_receive(SOCKET socket, struct sockaddr_in* rxAddr, u8* buffer, u16 bufferLength, u16* receiveLength, u8* localIndex) {
|
||||
*receiveLength = 0;
|
||||
|
||||
unsigned int rxAddrSize = sizeof(struct sockaddr_in);
|
||||
RX_ADDR_SIZE_TYPE rxAddrSize = sizeof(struct sockaddr_in);
|
||||
int rc = recvfrom(socket, (char*)buffer, bufferLength, 0, (struct sockaddr*)rxAddr, &rxAddrSize);
|
||||
|
||||
for (int i = 1; i < MAX_PLAYERS; i++) {
|
||||
|
|
|
@ -17,5 +17,6 @@
|
|||
#define closesocket(fd) close(fd)
|
||||
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
|
||||
#define SOCKET_ECONNRESET ECONNRESET
|
||||
#define RX_ADDR_SIZE_TYPE unsigned int
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,4 +7,6 @@
|
|||
#define SOCKET_LAST_ERROR WSAGetLastError()
|
||||
#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define SOCKET_ECONNRESET WSAECONNRESET
|
||||
#define RX_ADDR_SIZE_TYPE int
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue