mirror of
https://github.com/Cesarus85/ringfall-mjolnir-vr.git
synced 2026-10-17 23:00:26 +02:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b77fe428a |
No files matched your search
@@ -331,6 +331,8 @@ static struct
|
||||
unsigned char join_host_hash[P2P_KEY_HASH_SIZE];
|
||||
unsigned char join_token[P2P_TOKEN_SIZE];
|
||||
unsigned long join_time;
|
||||
/* how the latest join goes, for the menus (p2p_join_state) */
|
||||
int join_state;
|
||||
|
||||
char clipboard[P2P_LINK_SIZE];
|
||||
int has_clipboard;
|
||||
@@ -840,6 +842,12 @@ static void drop_peer(struct peer *peer, const char *reason)
|
||||
struct retired_session *retired = &p2p.retired[p2p.retired_next++ % MAXIMUM_RETIRED_SESSIONS];
|
||||
int ask_again = p2p.joining && peer->is_host && !memcmp(peer->identifier, p2p.join_host, P2P_IDENTIFIER_SIZE);
|
||||
|
||||
if (peer->is_host && !memcmp(peer->identifier, p2p.join_host, P2P_IDENTIFIER_SIZE) &&
|
||||
p2p.join_state != P2P_JOIN_NONE)
|
||||
{
|
||||
p2p.join_state = peer->connected ? P2P_JOIN_LOST : P2P_JOIN_BLOCKED;
|
||||
}
|
||||
|
||||
platform_log("Internet play: %s %s: %s", peer->is_host ? "host" : "player", peer->name, reason);
|
||||
if (peer->connected)
|
||||
{
|
||||
@@ -1029,6 +1037,8 @@ static void peer_heard(struct peer *peer, unsigned long address, unsigned short
|
||||
address_text(address, port, text));
|
||||
if (peer->is_host)
|
||||
{
|
||||
if (!memcmp(p2p.join_host, peer->identifier, P2P_IDENTIFIER_SIZE) && p2p.join_state != P2P_JOIN_NONE)
|
||||
p2p.join_state = P2P_JOIN_CONNECTED;
|
||||
if (p2p.joining && !memcmp(p2p.join_host, peer->identifier, P2P_IDENTIFIER_SIZE))
|
||||
{
|
||||
p2p.joining = 0;
|
||||
@@ -2298,6 +2308,7 @@ static int join_invite(const char *text)
|
||||
memcpy(p2p.join_host_hash, hash, sizeof(hash));
|
||||
memcpy(p2p.join_token, token, sizeof(token));
|
||||
p2p.join_requested = 1;
|
||||
p2p.join_state = P2P_JOIN_REACHING;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2344,6 +2355,16 @@ int p2p_join_code_status(void)
|
||||
return status;
|
||||
}
|
||||
|
||||
int p2p_join_state(void)
|
||||
{
|
||||
int state;
|
||||
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
state = p2p.running ? p2p.join_state : P2P_JOIN_NONE;
|
||||
pthread_mutex_unlock(&p2p_lock);
|
||||
return state;
|
||||
}
|
||||
|
||||
void p2p_join_code_clear_status(void)
|
||||
{
|
||||
pthread_mutex_lock(&p2p_lock);
|
||||
@@ -2381,6 +2402,8 @@ static void update_joining(void)
|
||||
{
|
||||
p2p.joining = 0;
|
||||
p2p_signal_stop_joining();
|
||||
if (p2p.join_state == P2P_JOIN_REACHING)
|
||||
p2p.join_state = P2P_JOIN_NO_ANSWER;
|
||||
platform_log("Internet play: no answer from the invite's host; it may have stopped hosting or quit");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,19 @@ int p2p_join_code(char *text, int size);
|
||||
int p2p_join_with_code(const char *typed);
|
||||
int p2p_join_code_status(void);
|
||||
void p2p_join_code_clear_status(void);
|
||||
/* how the latest join of an invite or code goes (the VR port's, for the
|
||||
menus): reaching the host, connected (its game is in the system link list),
|
||||
or why not */
|
||||
enum
|
||||
{
|
||||
P2P_JOIN_NONE,
|
||||
P2P_JOIN_REACHING,
|
||||
P2P_JOIN_CONNECTED,
|
||||
P2P_JOIN_NO_ANSWER,
|
||||
P2P_JOIN_BLOCKED,
|
||||
P2P_JOIN_LOST,
|
||||
};
|
||||
int p2p_join_state(void);
|
||||
|
||||
/* this machine's identifier, which its XNADDR carries (6 bytes) */
|
||||
const unsigned char *p2p_identifier(void);
|
||||
|
||||
@@ -5602,6 +5602,7 @@ int p2p_join_code(char *text, int size);
|
||||
int p2p_join_with_code(char const *typed);
|
||||
int p2p_join_code_status(void);
|
||||
void p2p_join_code_clear_status(void);
|
||||
int p2p_join_state(void);
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -5615,6 +5616,17 @@ enum
|
||||
_join_code_offline,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
/* p2p.h's */
|
||||
_join_state_none,
|
||||
_join_state_reaching,
|
||||
_join_state_connected,
|
||||
_join_state_no_answer,
|
||||
_join_state_blocked,
|
||||
_join_state_lost,
|
||||
};
|
||||
|
||||
static struct
|
||||
{
|
||||
boolean keyboard_launched;
|
||||
@@ -5723,6 +5735,18 @@ static void ui_join_code_render(
|
||||
case _join_code_own: status = "That is this game's own code"; break;
|
||||
case _join_code_offline: status = "Online play is off (network.online in config.toml)"; break;
|
||||
}
|
||||
/* (the code found, or a link: how reaching its host goes) */
|
||||
if (!status || p2p_join_code_status() == _join_code_found)
|
||||
{
|
||||
switch (p2p_join_state())
|
||||
{
|
||||
case _join_state_reaching: status = "Reaching the online game's host..."; break;
|
||||
case _join_state_connected: status = "Connected: the online game is in the list above"; break;
|
||||
case _join_state_no_answer: status = "The host did not answer: it may have stopped hosting"; break;
|
||||
case _join_state_blocked: status = "Blocked by the routers: allow UPnP on yours or the host's"; break;
|
||||
case _join_state_lost: status = "Lost the connection to the online game's host"; break;
|
||||
}
|
||||
}
|
||||
if (status)
|
||||
ui_join_code_draw_line(392, status, FALSE, FALSE);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user