Some networking/matchmaking improvements.

This commit is contained in:
Mr_Goldberg 2020-03-03 09:04:04 -05:00
parent 0e72e995ee
commit a0b66407bf
No known key found for this signature in database
GPG key ID: 8597D87419DEF278
4 changed files with 20 additions and 7 deletions

View file

@ -1141,6 +1141,16 @@ bool Networking::sendToIPPort(Common_Message *msg, uint32 ip, uint16 port, bool
return true;
}
uint32 Networking::getIP(CSteamID id)
{
Connection *conn = find_connection(id, this->appid);
if (conn) {
return ntohl(conn->tcp_ip_port.ip);
}
return 0;
}
bool Networking::sendTo(Common_Message *msg, bool reliable, Connection *conn)
{
if (!enabled) return false;

View file

@ -135,6 +135,7 @@ public:
bool sendToIPPort(Common_Message *msg, uint32 ip, uint16 port, bool reliable);
bool setCallback(Callback_Ids id, CSteamID steam_id, void (*message_callback)(void *object, Common_Message *msg), void *object);
uint32 getIP(CSteamID id);
uint32 getOwnIP();
void shutDown();

View file

@ -113,7 +113,7 @@ void send_lobby_data()
}
}
void trigger_lobby_dataupdate(CSteamID lobby, CSteamID member, bool success, double cb_timeout=0.0, bool send_changed_lobby=true)
void trigger_lobby_dataupdate(CSteamID lobby, CSteamID member, bool success, double cb_timeout=0.005, bool send_changed_lobby=true)
{
PRINT_DEBUG("Lobby dataupdate %llu %llu\n", lobby.ConvertToUint64(), member.ConvertToUint64());
LobbyDataUpdate_t data;
@ -1092,8 +1092,11 @@ CSteamID GetLobbyOwner( CSteamID steamIDLobby )
PRINT_DEBUG("GetLobbyOwner %llu\n", steamIDLobby.ConvertToUint64());
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Lobby *lobby = get_lobby(steamIDLobby);
if (!lobby || lobby->deleted()) return k_steamIDNil;
Lobby_Member *member = get_lobby_member(lobby, settings->get_local_steam_id());
CSteamID id = k_steamIDNil;
if (lobby) id = (uint64)lobby->owner();
if (member) id = (uint64)lobby->owner();
return id;
}

View file

@ -453,9 +453,8 @@ bool GetP2PSessionState( CSteamID steamIDRemote, P2PSessionState_t *pConnectionS
pConnectionState->m_bUsingRelay = false;
pConnectionState->m_nBytesQueuedForSend = 0;
pConnectionState->m_nPacketsQueuedForSend = 0;
//TODO ip?
pConnectionState->m_nRemoteIP = 0;
pConnectionState->m_nRemotePort = 0;
pConnectionState->m_nRemoteIP = network->getIP(steamIDRemote);
pConnectionState->m_nRemotePort = 12345;
}
PRINT_DEBUG("Connection\n");
@ -470,7 +469,7 @@ bool GetP2PSessionState( CSteamID steamIDRemote, P2PSessionState_t *pConnectionS
// P2P packet relay is allowed by default
bool AllowP2PPacketRelay( bool bAllow )
{
PRINT_DEBUG("Steam_Networking::AllowP2PPacketRelay\n");
PRINT_DEBUG("Steam_Networking::AllowP2PPacketRelay %u\n", bAllow);
return true;
}