auto-search/replace

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-08-02 16:07:23 -07:00
parent d5c491a694
commit 061cb98f74
33 changed files with 179 additions and 184 deletions
@@ -417,7 +417,7 @@ namespace GridMate
{
GM_CLASS_ALLOCATOR(Connection); // make a pool and use it...
Connection(CarrierThread* threadOwner, const string& address);
Connection(CarrierThread* threadOwner, const AZStd::string& address);
~Connection();
CarrierThread* m_threadOwner; ///< Pointer to the carrier thread that operates with this connection.
@@ -999,7 +999,7 @@ namespace GridMate
/// Connect with host and port. This is ASync operation, the connection is active after OnConnectionEstablished is called.
ConnectionID Connect(const char* hostAddress, unsigned int port) override;
/// Connect with internal address format. This is ASync operation, the connection is active after OnConnectionEstablished is called.
ConnectionID Connect(const string& address) override;
ConnectionID Connect(const AZStd::string& address) override;
/// Request a disconnect procedure. This is ASync operation, the connection is closed after OnDisconnect is called.
void Disconnect(ConnectionID id) override;
@@ -1118,7 +1118,7 @@ using namespace GridMate;
// Connection
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
Connection::Connection(CarrierThread* threadOwner, const string& address)
Connection::Connection(CarrierThread* threadOwner, const AZStd::string& address)
: m_threadOwner(threadOwner)
, m_threadConn(NULL)
, m_fullAddress(address)
@@ -3740,7 +3740,7 @@ CarrierImpl::Connect(const char* hostAddress, unsigned int port)
// [1/12/2011]
//=========================================================================
ConnectionID
CarrierImpl::Connect(const string& address)
CarrierImpl::Connect(const AZStd::string& address)
{
// check if we don't have it in the list.
for(auto& i : m_connections)
@@ -88,7 +88,7 @@ namespace GridMate
/// Connect with host and port. This is ASync operation, the connection is active after OnConnectionEstablished is called.
virtual ConnectionID Connect(const char* hostAddress, unsigned int port) = 0;
/// Connect with internal address format. This is ASync operation, the connection is active after OnConnectionEstablished is called.
virtual ConnectionID Connect(const string& address) = 0;
virtual ConnectionID Connect(const AZStd::string& address) = 0;
/// Request a disconnect procedure. This is ASync operation, the connection is closed after OnDisconnect is called.
virtual void Disconnect(ConnectionID id) = 0;
@@ -98,7 +98,7 @@ DefaultHandshake::OnConfirmAck(ConnectionID id, ReadBuffer& rb)
// [11/5/2010]
//=========================================================================
bool
DefaultHandshake::OnNewConnection(const string& address)
DefaultHandshake::OnNewConnection(const AZStd::string& address)
{
(void)address;
return true; /// We don't have a ban list yet
@@ -47,7 +47,7 @@ namespace GridMate
*/
virtual bool OnConfirmAck(ConnectionID id, ReadBuffer& rb);
/// Return true if you want to reject early reject a connection.
virtual bool OnNewConnection(const string& address);
virtual bool OnNewConnection(const AZStd::string& address);
/// Called when we close a connection.
virtual void OnDisconnect(ConnectionID id);
/// Return timeout in milliseconds of the handshake procedure.
@@ -140,7 +140,7 @@ namespace GridMate
/// @{ Address conversion functionality. They MUST implemented thread safe. Generally this is not a problem since they just part local data.
/// Create address from ip and port. If ip == NULL we will assign a broadcast address.
virtual string IPPortToAddress(const char* ip, unsigned int port) const = 0;
virtual bool AddressToIPPort(const string& address, string& ip, unsigned int& port) const = 0;
virtual bool AddressToIPPort(const AZStd::string& address, AZStd::string& ip, unsigned int& port) const = 0;
/// @}
/**
@@ -150,7 +150,7 @@ namespace GridMate
* \note Driver address allocates internal resources, use it only when you intend to communicate. Otherwise operate with
* the string address.
*/
virtual AZStd::intrusive_ptr<DriverAddress> CreateDriverAddress(const string& address) = 0;
virtual AZStd::intrusive_ptr<DriverAddress> CreateDriverAddress(const AZStd::string& address) = 0;
/**
* Returns true if the driver can accept new data (ex, has buffer space).
@@ -53,7 +53,7 @@ namespace GridMate
*/
virtual bool OnConfirmAck(ConnectionID id, ReadBuffer& rb) = 0;
/// Return true if you want to reject early reject a connection.
virtual bool OnNewConnection(const string& address) = 0;
virtual bool OnNewConnection(const AZStd::string& address) = 0;
/// Called when we close a connection.
virtual void OnDisconnect(ConnectionID id) = 0;
/// Return timeout in milliseconds of the handshake procedure.
@@ -498,7 +498,7 @@ namespace GridMate
}
}
SocketDriverAddress::SocketDriverAddress(Driver* driver, const string& ip, unsigned int port)
SocketDriverAddress::SocketDriverAddress(Driver* driver, const AZStd::string& ip, unsigned int port)
: DriverAddress(driver)
{
AZ_Assert(!ip.empty(), "Invalid address string!");
@@ -1156,7 +1156,7 @@ namespace GridMate
// [3/4/2013]
//=========================================================================
bool
SocketDriverCommon::AddressStringToIPPort(const string& address, string& ip, unsigned int& port)
SocketDriverCommon::AddressStringToIPPort(const AZStd::string& address, AZStd::string& ip, unsigned int& port)
{
AZStd::size_t pos = address.find('|');
AZ_Assert(pos != string::npos, "Invalid driver address!");
@@ -1176,7 +1176,7 @@ namespace GridMate
// [7/11/2013]
//=========================================================================
Driver::BSDSocketFamilyType
SocketDriverCommon::AddressFamilyType(const string& ip)
SocketDriverCommon::AddressFamilyType(const AZStd::string& ip)
{
// TODO: We can/should use inet_ntop() to detect the family type
AZStd::size_t pos = ip.find(".");
@@ -1198,13 +1198,13 @@ namespace GridMate
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//=========================================================================
// CreateDriverAddress(const string&)
// CreateDriverAddress(const AZStd::string&)
// [1/12/2011]
//=========================================================================
AZStd::intrusive_ptr<DriverAddress>
SocketDriver::CreateDriverAddress(const string& address)
SocketDriver::CreateDriverAddress(const AZStd::string& address)
{
string ip;
AZStd::string ip;
unsigned int port;
if (!AddressToIPPort(address, ip, port))
{
@@ -1243,7 +1243,7 @@ namespace GridMate
namespace Utils
{
// \note function moved here to use addinfo when IPV6 is not in use, consider moving those definitions to a header file
bool GetIpByHostName(int familyType, const char* hostName, string& ip)
bool GetIpByHostName(int familyType, const char* hostName, AZStd::string& ip)
{
static const size_t kMaxLen = 64; // max length of ipv6 ip is 45 chars, so all ips should be able to fit in this buf
char ipBuf[kMaxLen];
@@ -83,7 +83,7 @@ namespace GridMate
SocketDriverAddress(Driver* driver);
SocketDriverAddress(Driver* driver, const sockaddr* addr);
SocketDriverAddress(Driver* driver, const string& ip, unsigned int port);
SocketDriverAddress(Driver* driver, const AZStd::string& ip, unsigned int port);
bool operator==(const SocketDriverAddress& rhs) const;
bool operator!=(const SocketDriverAddress& rhs) const;
@@ -164,17 +164,17 @@ namespace GridMate
/// @{ Address conversion functionality. They MUST implemented thread safe. Generally this is not a problem since they just part local data.
/// Create address from ip and port. If ip == NULL we will assign a broadcast address.
virtual string IPPortToAddress(const char* ip, unsigned int port) const { return IPPortToAddressString(ip, port); }
virtual bool AddressToIPPort(const string& address, string& ip, unsigned int& port) const { return AddressStringToIPPort(address, ip, port); }
virtual bool AddressToIPPort(const AZStd::string& address, AZStd::string& ip, unsigned int& port) const { return AddressStringToIPPort(address, ip, port); }
/// Create address for the socket driver from IP and port
static string IPPortToAddressString(const char* ip, unsigned int port);
/// Decompose an address to IP and port
static bool AddressStringToIPPort(const string& address, string& ip, unsigned int& port);
static bool AddressStringToIPPort(const AZStd::string& address, AZStd::string& ip, unsigned int& port);
/// Return the family type of the address (AF_INET,AF_INET6 AF_UNSPEC)
static BSDSocketFamilyType AddressFamilyType(const string& ip);
static BSDSocketFamilyType AddressFamilyType(const AZStd::string& ip);
static BSDSocketFamilyType AddressFamilyType(const char* ip) { return AddressFamilyType(string(ip)); }
/// @}
virtual AZStd::intrusive_ptr<DriverAddress> CreateDriverAddress(const string& address) = 0;
virtual AZStd::intrusive_ptr<DriverAddress> CreateDriverAddress(const AZStd::string& address) = 0;
/// Additional CreateDriverAddress function should be implemented.
virtual AZStd::intrusive_ptr<DriverAddress> CreateDriverAddress(const sockaddr* sockAddr) = 0;
@@ -352,7 +352,7 @@ namespace GridMate
* \note Driver address allocates internal resources, use it only when you intend to communicate. Otherwise operate with
* the string address.
*/
virtual AZStd::intrusive_ptr<DriverAddress> CreateDriverAddress(const string& address);
virtual AZStd::intrusive_ptr<DriverAddress> CreateDriverAddress(const AZStd::string& address);
virtual AZStd::intrusive_ptr<DriverAddress> CreateDriverAddress(const sockaddr* addr);
/// Called only from the DriverAddress when the use count becomes 0
virtual void DestroyDriverAddress(DriverAddress* address);
@@ -364,7 +364,7 @@ namespace GridMate
namespace Utils
{
///< Retrieves ip address corresponding to a host name. Blocks thread until dns resolving is happened.
bool GetIpByHostName(int familyType, const char* hostName, string& ip);
bool GetIpByHostName(int familyType, const char* hostName, AZStd::string& ip);
}
/**
@@ -224,7 +224,7 @@ namespace GridMate
// [4/15/2011]
//=========================================================================
void
SessionDriller::OnSessionError(GridSession* session, const string& errorMsg)
SessionDriller::OnSessionError(GridSession* session, const AZStd::string& errorMsg)
{
m_output->BeginTag(m_drillerTag);
m_output->BeginTag(AZ_CRC("SessionError", 0xc689cc40));
@@ -62,7 +62,7 @@ namespace GridMate
/// Callback that notifies the title when a session will be left. session pointer is NOT valid after the callback returns.
virtual void OnSessionDelete(GridSession* session);
/// Called when a session error occurs.
virtual void OnSessionError(GridSession* session, const string& errorMsg);
virtual void OnSessionError(GridSession* session, const AZStd::string& errorMsg);
/// Called when the actual game(match) starts
virtual void OnSessionStart(GridSession* session);
/// Called when the actual game(match) ends
@@ -37,7 +37,7 @@ namespace GridMate
{
friend class LANMemberIDMarshaler;
static LANMemberID Create(MemberIDCompact id, const string& address)
static LANMemberID Create(MemberIDCompact id, const AZStd::string& address)
{
LANMemberID mid;
mid.m_id = id;
@@ -45,7 +45,7 @@ namespace GridMate
return mid;
}
void SetAddress(const string& address)
void SetAddress(const AZStd::string& address)
{
m_address = address;
}
@@ -120,14 +120,14 @@ namespace GridMate
/// Creates the local player.
GridMember* CreateLocalMember(bool isHost, bool isInvited, RemotePeerMode peerMode);
/// Creates remote player, when he wants to join.
GridMember* CreateRemoteMember(const string& address, ReadBuffer& data, RemotePeerMode peerMode, ConnectionID connId = InvalidConnectionID) override;
GridMember* CreateRemoteMember(const AZStd::string& address, ReadBuffer& data, RemotePeerMode peerMode, ConnectionID connId = InvalidConnectionID) override;
/// Called when we receive the session replica. We create one and return the pointer.
LANSessionReplica* OnSessionReplicaArrived();
/// Called when session parameters have changed.
void OnSessionParamChanged(const GridSessionParam& param) override { (void)param; }
void OnSessionParamRemoved(const string& paramId) override { (void)paramId; }
void OnSessionParamRemoved(const AZStd::string& paramId) override { (void)paramId; }
private:
explicit LANSession(LANSessionService* service);
@@ -762,7 +762,7 @@ LANSession::CreateLocalMember(bool isHost, bool isInvited, RemotePeerMode peerMo
// [2/2/2011]
//==========================================================================
GridMember*
LANSession::CreateRemoteMember(const string& address, ReadBuffer& data, RemotePeerMode peerMode, ConnectionID connId)
LANSession::CreateRemoteMember(const AZStd::string& address, ReadBuffer& data, RemotePeerMode peerMode, ConnectionID connId)
{
MemberIDCompact id;
data.Read(id);
@@ -803,7 +803,7 @@ LANSession::OnStateCreate(AZ::HSM& sm, const AZ::HSM::Event& e)
{
// patch the ID if we use implicit port
AZ_Assert(m_carrier, "Carrier must be created!");
string ip;
AZStd::string ip;
unsigned int port;
SocketDriverCommon::AddressStringToIPPort(m_myMember->GetId().ToAddress(), ip, port);
AZ_Assert(port == 0 || port == m_carrier->GetPort(), "Carrier port missmatch! It should either be 0 (and patched here) in the implicit bind or the port number for explicit bind!");
@@ -39,9 +39,9 @@ namespace GridMate
{}
int m_familyType; ///< Socket driver specific, by default 0.
string m_serverAddress; ///< Address of the server, we empty we create a broadcast address.
AZStd::string m_serverAddress; ///< Address of the server, we empty we create a broadcast address.
int m_serverPort; ///< Server port (must be provided).
string m_listenAddress; ///< Address to bind for listening. By default is empty, which means we are listening to any address.
AZStd::string m_listenAddress; ///< Address to bind for listening. By default is empty, which means we are listening to any address.
int m_listenPort; ///< Search listen port, if not set we will use ephimeral port.
unsigned int m_broadcastFrequencyMs; ///< Time in MS between search broadcasts.
};
@@ -52,7 +52,7 @@ namespace GridMate
struct LANSearchInfo
: public SearchInfo
{
string m_serverIP; ///< server ID as we see it
AZStd::string m_serverIP; ///< server ID as we see it
AZ::u16 m_serverPort; ///< server port for the session
};
}
@@ -92,7 +92,7 @@ namespace GridMate
*/
virtual bool OnConfirmAck(ConnectionID id, ReadBuffer& rb) { (void)id; (void)rb; return true; } // we don't do any further filtering
/// Return true if you want to reject early reject a connection.
virtual bool OnNewConnection(const string& address);
virtual bool OnNewConnection(const AZStd::string& address);
/// Called when we close a connection.
virtual void OnDisconnect(ConnectionID id);
/// Return timeout in milliseconds of the handshake procedure.
@@ -684,7 +684,7 @@ GridSession::SetParam(const GridSessionParam& param)
// RemoveParam
//=========================================================================
bool
GridSession::RemoveParam(const string& paramId)
GridSession::RemoveParam(const AZStd::string& paramId)
{
AZ_Assert(m_state, "Invalid session state replica. Session is not initialized.");
@@ -970,7 +970,7 @@ GridSession::AddMember(GridMember* member)
// IsAddressInMemberList
//=========================================================================
bool
GridSession::IsAddressInMemberList(const string& address)
GridSession::IsAddressInMemberList(const AZStd::string& address)
{
for (AZStd::size_t i = 0; i < m_members.size(); ++i)
{
@@ -2783,7 +2783,7 @@ bool GridSessionHandshake::OnConfirmRequest(ConnectionID id, ReadBuffer& rb)
//=========================================================================
// OnNewConnection
//=========================================================================
bool GridSessionHandshake::OnNewConnection(const string& address)
bool GridSessionHandshake::OnNewConnection(const AZStd::string& address)
{
AZStd::lock_guard<AZStd::mutex> l(m_dataLock);
@@ -249,7 +249,7 @@ namespace GridMate
/// Callback that notifies the title when a session will be left. session pointer is NOT valid after the callback returns.
virtual void OnSessionDelete(GridSession* session) { (void)session; }
/// Called when a session error occurs.
virtual void OnSessionError(GridSession* session, const string& errorMsg) { (void)session; (void)errorMsg; }
virtual void OnSessionError(GridSession* session, const AZStd::string& errorMsg) { (void)session; (void)errorMsg; }
/// Called when the actual game(match) starts
virtual void OnSessionStart(GridSession* session) { (void)session; }
/// Called when the actual game(match) ends
@@ -484,7 +484,7 @@ namespace GridMate
// Adds/updates a parameter. Returns false if parameter can not be added.
bool SetParam(const GridSessionParam& param);
// Removes a parameter by id. Returns false if parameter can not be removed.
bool RemoveParam(const string& paramId);
bool RemoveParam(const AZStd::string& paramId);
// Removes a parameter by index. Returns false if parameter can not be removed.
bool RemoveParam(unsigned int index);
@@ -543,9 +543,9 @@ namespace GridMate
/// Frees a slot based on a slot type.
void FreeSlot(int slotType);
/// Creates remote player, when he wants to join.
virtual GridMember* CreateRemoteMember(const string& address, ReadBuffer& data, RemotePeerMode peerMode, ConnectionID connId = InvalidConnectionID) = 0;
virtual GridMember* CreateRemoteMember(const AZStd::string& address, ReadBuffer& data, RemotePeerMode peerMode, ConnectionID connId = InvalidConnectionID) = 0;
/// Returns true if this address belongs to a member in the list, otherwise false.
virtual bool IsAddressInMemberList(const string& address);
virtual bool IsAddressInMemberList(const AZStd::string& address);
virtual bool IsConnectionIdInMemberList(const ConnectionID& connId);
/// Adds a created member to the session. Return false if no free slow was found!
virtual bool AddMember(GridMember* member);
@@ -558,7 +558,7 @@ namespace GridMate
/// Called when a session parameter is added/changed.
virtual void OnSessionParamChanged(const GridSessionParam& param) = 0;
/// Called when a session parameter is deleted.
virtual void OnSessionParamRemoved(const string& paramId) = 0;
virtual void OnSessionParamRemoved(const AZStd::string& paramId) = 0;
//////////////////////////////////////////////////////////////////////////
SessionID m_sessionId; ///< Session id. Content of the string will vary based on session types and platforms.
@@ -975,7 +975,7 @@ namespace GridMate
/// Callback that notifies the title when a session will be left. session pointer is NOT valid after the callback returns.
virtual void OnSessionDelete(GridSession* session) { (void)session; }
/// Called when a session error occurs.
virtual void OnSessionError(GridSession* session, const string& errorMsg) { (void)session; (void)errorMsg; }
virtual void OnSessionError(GridSession* session, const AZStd::string& errorMsg) { (void)session; (void)errorMsg; }
/// Called when the actual game(match) starts
virtual void OnSessionStart(GridSession* session) { (void)session; }
/// Called when the actual game(match) ends
+6 -6
View File
@@ -241,7 +241,7 @@ namespace UnitTest
(void)reason;
}
void OnSessionError(GridSession* session, const string& /*errorMsg*/) override
void OnSessionError(GridSession* session, const AZStd::string& /*errorMsg*/) override
{
(void)session;
#ifndef AZ_LAN_TEST_MAIN_THREAD_BLOCKED // we will receive an error is we block for a long time
@@ -599,7 +599,7 @@ namespace UnitTest
(void)member;
(void)reason;
}
void OnSessionError(GridSession* session, const string& /*errorMsg*/) override
void OnSessionError(GridSession* session, const AZStd::string& /*errorMsg*/) override
{
(void)session;
AZ_TEST_ASSERT(false);
@@ -834,7 +834,7 @@ namespace UnitTest
(void)member;
(void)reason;
}
void OnSessionError(GridSession* session, const string& /*errorMsg*/) override
void OnSessionError(GridSession* session, const AZStd::string& /*errorMsg*/) override
{
(void)session;
#ifndef AZ_LAN_TEST_MAIN_THREAD_BLOCKED // we will receive an error is we block for a long time
@@ -1207,7 +1207,7 @@ namespace UnitTest
(void)member;
(void)reason;
}
void OnSessionError(GridSession* session, const string& /*errorMsg*/) override
void OnSessionError(GridSession* session, const AZStd::string& /*errorMsg*/) override
{
(void)session;
AZ_TEST_ASSERT(false);
@@ -1521,7 +1521,7 @@ namespace UnitTest
(void)member;
(void)reason;
}
void OnSessionError(GridSession* session, const string& /*errorMsg*/) override
void OnSessionError(GridSession* session, const AZStd::string& /*errorMsg*/) override
{
(void)session;
// On this test we will get a open port error because we have multiple hosts. This is ok, since we test migration here!
@@ -1861,7 +1861,7 @@ namespace UnitTest
(void)member;
(void)reason;
}
void OnSessionError(GridSession* session, const string& /*errorMsg*/) override
void OnSessionError(GridSession* session, const AZStd::string& /*errorMsg*/) override
{
(void)session;
// On this test we will get a open port error because we have multiple hosts. This is ok, since we test migration here!
@@ -34,7 +34,7 @@ static bool CollectPerformanceCounters(const AZ::Debug::ProfilerRegister& reg, c
return true;
}
static string FormatString(const string& pre, const string& name, const string& post, AZ::u64 time, AZ::u64 calls)
static string FormatString(const AZStd::string& pre, const AZStd::string& name, const AZStd::string& post, AZ::u64 time, AZ::u64 calls)
{
string units = "us";
if (AZ::u64 divtime = time / 1000)