Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetClient.cpp
Show All 27 Lines | |||||
#include "lib/external_libraries/libsdl.h" | #include "lib/external_libraries/libsdl.h" | ||||
#include "lib/sysdep/sysdep.h" | #include "lib/sysdep/sysdep.h" | ||||
#include "lobby/IXmppClient.h" | #include "lobby/IXmppClient.h" | ||||
#include "ps/CConsole.h" | #include "ps/CConsole.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/Compress.h" | #include "ps/Compress.h" | ||||
#include "ps/CStr.h" | #include "ps/CStr.h" | ||||
#include "ps/Game.h" | #include "ps/Game.h" | ||||
#include "ps/Hashing.h" | |||||
#include "ps/Loader.h" | #include "ps/Loader.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "ps/Threading.h" | #include "ps/Threading.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#include "network/StunClient.h" | #include "network/StunClient.h" | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | |||||
void CNetClient::SetHostJID(const CStr& jid) | void CNetClient::SetHostJID(const CStr& jid) | ||||
{ | { | ||||
m_HostJID = jid; | m_HostJID = jid; | ||||
} | } | ||||
void CNetClient::SetGamePassword(const CStr& hashedPassword) | void CNetClient::SetGamePassword(const CStr& hashedPassword) | ||||
{ | { | ||||
m_Password = hashedPassword; | // Hash on top with the user's name, to make sure not all | ||||
// hashing data is in control of the host. | |||||
m_Password = HashPassword(hashedPassword, m_UserName.ToUTF8()); | |||||
} | } | ||||
void CNetClient::SetControllerSecret(const std::string& secret) | void CNetClient::SetControllerSecret(const std::string& secret) | ||||
{ | { | ||||
m_ControllerSecret = secret; | m_ControllerSecret = secret; | ||||
} | } | ||||
bool CNetClient::SetupConnection(ENetHost* enetClient) | bool CNetClient::SetupConnection(ENetHost* enetClient) | ||||
{ | { | ||||
CNetClientSession* session = new CNetClientSession(*this); | CNetClientSession* session = new CNetClientSession(*this); | ||||
bool ok = session->Connect(m_ServerAddress, m_ServerPort, enetClient); | bool ok = session->Connect(m_ServerAddress, m_ServerPort, enetClient); | ||||
SetAndOwnSession(session); | SetAndOwnSession(session); | ||||
m_PollingThread = std::thread(Threading::HandleExceptions<CNetClientSession::RunNetLoop>::Wrapper, m_Session); | m_PollingThread = std::thread(Threading::HandleExceptions<CNetClientSession::RunNetLoop>::Wrapper, m_Session); | ||||
return ok; | return ok; | ||||
} | } | ||||
void CNetClient::SetupConnectionViaLobby() | |||||
{ | |||||
g_XmppClient->SendIqGetConnectionData(m_HostJID, m_Password, m_UserName.ToUTF8()); | |||||
} | |||||
void CNetClient::SetupServerData(CStr address, u16 port, bool stun) | void CNetClient::SetupServerData(CStr address, u16 port, bool stun) | ||||
{ | { | ||||
ENSURE(!m_Session); | ENSURE(!m_Session); | ||||
m_ServerAddress = address; | m_ServerAddress = address; | ||||
m_ServerPort = port; | m_ServerPort = port; | ||||
m_UseSTUN = stun; | m_UseSTUN = stun; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 759 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator