mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 03:55:11 +00:00
Add coopnet defines
This commit is contained in:
parent
2e854cda60
commit
b79db3b203
6 changed files with 34 additions and 10 deletions
6
Makefile
6
Makefile
|
@ -52,6 +52,8 @@ EXTERNAL_DATA ?= 0
|
||||||
DISCORDRPC ?= 0
|
DISCORDRPC ?= 0
|
||||||
# Enable Discord Game SDK (used for Discord server hosting)
|
# Enable Discord Game SDK (used for Discord server hosting)
|
||||||
DISCORD_SDK ?= 1
|
DISCORD_SDK ?= 1
|
||||||
|
# Enable CoopNet SDK (used for CoopNet server hosting)
|
||||||
|
COOPNET ?= 1
|
||||||
# Enable docker build workarounds
|
# Enable docker build workarounds
|
||||||
DOCKERBUILD ?= 0
|
DOCKERBUILD ?= 0
|
||||||
# Sets your optimization level for building.
|
# Sets your optimization level for building.
|
||||||
|
@ -982,7 +984,9 @@ else
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# coopnet
|
# coopnet
|
||||||
LDFLAGS += -Llib/coopnet/linux -l:libcoopnet.a -l:libjuice.a
|
ifeq ($(COOPNET),1)
|
||||||
|
LDFLAGS += -Llib/coopnet/linux -l:libcoopnet.a -l:libjuice.a
|
||||||
|
endif
|
||||||
#ifeq ($(WINDOWS_BUILD),1)
|
#ifeq ($(WINDOWS_BUILD),1)
|
||||||
# ifeq ($(TARGET_BITS), 32)
|
# ifeq ($(TARGET_BITS), 32)
|
||||||
# LDFLAGS += -Llib/coopnet/win32 -l:libcoopnet.a
|
# LDFLAGS += -Llib/coopnet/win32 -l:libcoopnet.a
|
||||||
|
|
|
@ -16,9 +16,19 @@ struct DjuiInputbox* sInputboxPort = NULL;
|
||||||
|
|
||||||
static void djui_panel_host_network_system_change(UNUSED struct DjuiBase* base) {
|
static void djui_panel_host_network_system_change(UNUSED struct DjuiBase* base) {
|
||||||
#ifndef DISCORD_SDK
|
#ifndef DISCORD_SDK
|
||||||
struct DjuiSelectionbox* selectionbox = (struct DjuiSelectionbox*) base;
|
{
|
||||||
if (selectionbox->value == NS_DISCORD) {
|
struct DjuiSelectionbox* selectionbox = (struct DjuiSelectionbox*) base;
|
||||||
selectionbox->value = NS_SOCKET;
|
if (*selectionbox->value == NS_DISCORD) {
|
||||||
|
selectionbox->value = NS_SOCKET;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifndef COOPNET
|
||||||
|
{
|
||||||
|
struct DjuiSelectionbox* selectionbox = (struct DjuiSelectionbox*) base;
|
||||||
|
if (*selectionbox->value == NS_COOPNET) {
|
||||||
|
selectionbox->value = NS_SOCKET;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
djui_base_set_enabled(&sInputboxPort->base, (configNetworkSystem == NS_SOCKET));
|
djui_base_set_enabled(&sInputboxPort->base, (configNetworkSystem == NS_SOCKET));
|
||||||
|
|
|
@ -23,6 +23,9 @@ void djui_panel_do_host(void) {
|
||||||
|
|
||||||
#ifndef DISCORD_SDK
|
#ifndef DISCORD_SDK
|
||||||
if (configNetworkSystem == NS_DISCORD) { configNetworkSystem = NS_COOPNET; }
|
if (configNetworkSystem == NS_DISCORD) { configNetworkSystem = NS_COOPNET; }
|
||||||
|
#endif
|
||||||
|
#ifndef COOPNET
|
||||||
|
if (configNetworkSystem == NS_COOPNET) { configNetworkSystem = NS_SOCKET; }
|
||||||
#endif
|
#endif
|
||||||
if (configNetworkSystem >= NS_MAX) { configNetworkSystem = NS_MAX; }
|
if (configNetworkSystem >= NS_MAX) { configNetworkSystem = NS_MAX; }
|
||||||
network_set_system(configNetworkSystem);
|
network_set_system(configNetworkSystem);
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include "pc/network/network.h"
|
#include "pc/network/network.h"
|
||||||
#include "pc/debuglog.h"
|
#include "pc/debuglog.h"
|
||||||
|
|
||||||
|
#ifdef COOPNET
|
||||||
|
|
||||||
#define HOST "localhost"
|
#define HOST "localhost"
|
||||||
#define PORT 34197
|
#define PORT 34197
|
||||||
|
|
||||||
|
@ -30,9 +32,6 @@ static void coopnet_on_connected(uint64_t userId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void coopnet_on_peer_connected(UNUSED uint64_t peerId) {
|
|
||||||
}
|
|
||||||
|
|
||||||
static void coopnet_on_peer_disconnected(uint64_t peerId) {
|
static void coopnet_on_peer_disconnected(uint64_t peerId) {
|
||||||
u8 localIndex = coopnet_user_id_to_local_index(peerId);
|
u8 localIndex = coopnet_user_id_to_local_index(peerId);
|
||||||
if (localIndex != UNKNOWN_LOCAL_INDEX && gNetworkPlayers[localIndex].connected) {
|
if (localIndex != UNKNOWN_LOCAL_INDEX && gNetworkPlayers[localIndex].connected) {
|
||||||
|
@ -56,7 +55,6 @@ static void coopnet_on_lobby_joined(uint64_t lobbyId, uint64_t userId, uint64_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void coopnet_on_lobby_left(uint64_t lobbyId, uint64_t userId) {
|
static void coopnet_on_lobby_left(uint64_t lobbyId, uint64_t userId) {
|
||||||
LOG_INFO("coopnet_on_lobby_left!");
|
LOG_INFO("coopnet_on_lobby_left!");
|
||||||
if (lobbyId == sLocalLobbyId && userId == sLocalUserId) {
|
if (lobbyId == sLocalLobbyId && userId == sLocalUserId) {
|
||||||
|
@ -73,7 +71,6 @@ static bool ns_coopnet_initialize(enum NetworkType networkType) {
|
||||||
gCoopNetCallbacks.OnReceive = coopnet_on_receive;
|
gCoopNetCallbacks.OnReceive = coopnet_on_receive;
|
||||||
gCoopNetCallbacks.OnLobbyJoined = coopnet_on_lobby_joined;
|
gCoopNetCallbacks.OnLobbyJoined = coopnet_on_lobby_joined;
|
||||||
gCoopNetCallbacks.OnLobbyLeft = coopnet_on_lobby_left;
|
gCoopNetCallbacks.OnLobbyLeft = coopnet_on_lobby_left;
|
||||||
gCoopNetCallbacks.OnPeerConnected = coopnet_on_peer_connected;
|
|
||||||
gCoopNetCallbacks.OnPeerDisconnected = coopnet_on_peer_disconnected;
|
gCoopNetCallbacks.OnPeerDisconnected = coopnet_on_peer_disconnected;
|
||||||
sNetworkType = networkType;
|
sNetworkType = networkType;
|
||||||
|
|
||||||
|
@ -150,3 +147,5 @@ struct NetworkSystem gNetworkSystemCoopNet = {
|
||||||
.requireServerBroadcast = false,
|
.requireServerBroadcast = false,
|
||||||
.name = "CoopNet",
|
.name = "CoopNet",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef COOPNET_H
|
#ifndef COOPNET_H
|
||||||
#define COOPNET_H
|
#define COOPNET_H
|
||||||
|
#ifdef COOPNET
|
||||||
|
|
||||||
extern struct NetworkSystem gNetworkSystemCoopNet;
|
extern struct NetworkSystem gNetworkSystemCoopNet;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
|
@ -85,13 +85,19 @@ struct ServerSettings gServerSettings = {
|
||||||
|
|
||||||
void network_set_system(enum NetworkSystemType nsType) {
|
void network_set_system(enum NetworkSystemType nsType) {
|
||||||
network_forget_all_reliable();
|
network_forget_all_reliable();
|
||||||
|
|
||||||
switch (nsType) {
|
switch (nsType) {
|
||||||
case NS_SOCKET: gNetworkSystem = &gNetworkSystemSocket; break;
|
case NS_SOCKET: gNetworkSystem = &gNetworkSystemSocket; break;
|
||||||
|
|
||||||
#ifdef DISCORD_SDK
|
#ifdef DISCORD_SDK
|
||||||
case NS_DISCORD: gNetworkSystem = &gNetworkSystemDiscord; break;
|
case NS_DISCORD: gNetworkSystem = &gNetworkSystemDiscord; break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef COOPNET
|
||||||
case NS_COOPNET: gNetworkSystem = &gNetworkSystemCoopNet; break;
|
case NS_COOPNET: gNetworkSystem = &gNetworkSystemCoopNet; break;
|
||||||
default: LOG_ERROR("Unknown network system: %d", nsType);
|
#endif
|
||||||
|
|
||||||
|
default: gNetworkSystem = &gNetworkSystemSocket; LOG_ERROR("Unknown network system: %d", nsType); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue