Make coopnet IP and Port configurable (Isaac)

This commit is contained in:
MysterD 2023-04-13 22:58:58 -07:00
parent 3f38c740d8
commit 29a8c391bb
3 changed files with 10 additions and 4 deletions

View file

@ -156,6 +156,8 @@ bool configDebugPrint = 0;
bool configDebugInfo = 0;
bool configDebugError = 0;
char configLanguage[MAX_CONFIG_STRING] = "";
char configCoopNetIp[MAX_CONFIG_STRING] = DEFAULT_COOPNET_IP;
unsigned int configCoopNetPort = DEFAULT_COOPNET_PORT;
static const struct ConfigOption options[] = {
{.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configWindow.fullscreen},
@ -264,6 +266,8 @@ static const struct ConfigOption options[] = {
{.name = "debug_info", .type = CONFIG_TYPE_BOOL , .boolValue = &configDebugInfo},
{.name = "debug_error", .type = CONFIG_TYPE_BOOL , .boolValue = &configDebugError},
{.name = "language", .type = CONFIG_TYPE_STRING, .stringValue = (char*)&configLanguage, .maxStringLength = MAX_CONFIG_STRING},
{.name = "coopnet_ip", .type = CONFIG_TYPE_STRING, .stringValue = (char*)&configCoopNetIp, .maxStringLength = MAX_CONFIG_STRING},
{.name = "coopnet_port", .type = CONFIG_TYPE_UINT , .uintValue = &configCoopNetPort},
};
// FunctionConfigOption functions

View file

@ -15,6 +15,8 @@
#define MAX_DESCRIPTION_STRING 20
#define DEFAULT_PORT 7777
#define DEFAULT_COOPNET_IP "localhost"
#define DEFAULT_COOPNET_PORT 34197
typedef struct {
unsigned int x, y, w, h;
@ -111,6 +113,8 @@ extern bool configDebugPrint;
extern bool configDebugInfo;
extern bool configDebugError;
extern char configLanguage[];
extern char configCoopNetIp[];
extern unsigned int configCoopNetPort;
void configfile_load(void);
void configfile_save(const char *filename);

View file

@ -9,8 +9,6 @@
#ifdef COOPNET
#define CN_HOST "localhost"
#define CN_PORT 34197
#define CN_GAME_STR "sm64ex-coop"
uint64_t gCoopNetDesiredLobby = 0;
@ -138,7 +136,7 @@ static CoopNetRc coopnet_initialize(void) {
gCoopNetCallbacks.OnLobbyLeft = coopnet_on_lobby_left;
gCoopNetCallbacks.OnPeerDisconnected = coopnet_on_peer_disconnected;
CoopNetRc rc = coopnet_begin(CN_HOST, CN_PORT);
CoopNetRc rc = coopnet_begin(configCoopNetIp, configCoopNetPort);
if (rc == COOPNET_FAILED) {
djui_popup_create(DLANG(NOTIF, COOPNET_CONNECTION_FAILED), 2);
}
@ -160,4 +158,4 @@ struct NetworkSystem gNetworkSystemCoopNet = {
.name = "CoopNet",
};
#endif
#endif