mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 09:57:26 +02:00
refactor the Agent copy constructor
This commit is contained in:
parent
f333aaf809
commit
12b4b485f0
1 changed files with 7 additions and 8 deletions
|
@ -55,9 +55,13 @@ Agent::Agent(sockaddr *publicSocket, sockaddr *localSocket, char type, uint16_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Agent::Agent(const Agent &otherAgent) {
|
Agent::Agent(const Agent &otherAgent) :
|
||||||
_isAlive = otherAgent._isAlive;
|
_type(otherAgent._type),
|
||||||
|
_agentID(otherAgent._agentID),
|
||||||
|
_wakeMicrostamp(otherAgent._wakeMicrostamp),
|
||||||
|
_lastHeardMicrostamp(otherAgent._lastHeardMicrostamp),
|
||||||
|
_isAlive(otherAgent._isAlive)
|
||||||
|
{
|
||||||
if (otherAgent._publicSocket) {
|
if (otherAgent._publicSocket) {
|
||||||
_publicSocket = new sockaddr(*otherAgent._localSocket);
|
_publicSocket = new sockaddr(*otherAgent._localSocket);
|
||||||
} else {
|
} else {
|
||||||
|
@ -70,7 +74,6 @@ Agent::Agent(const Agent &otherAgent) {
|
||||||
_localSocket = NULL;
|
_localSocket = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_agentID = otherAgent._agentID;
|
|
||||||
|
|
||||||
if (otherAgent._activeSocket == otherAgent._publicSocket) {
|
if (otherAgent._activeSocket == otherAgent._publicSocket) {
|
||||||
_activeSocket = _publicSocket;
|
_activeSocket = _publicSocket;
|
||||||
|
@ -80,10 +83,6 @@ Agent::Agent(const Agent &otherAgent) {
|
||||||
_activeSocket = NULL;
|
_activeSocket = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_wakeMicrostamp = otherAgent._wakeMicrostamp;
|
|
||||||
_lastHeardMicrostamp = otherAgent._lastHeardMicrostamp;
|
|
||||||
_type = otherAgent._type;
|
|
||||||
|
|
||||||
if (otherAgent._linkedData) {
|
if (otherAgent._linkedData) {
|
||||||
_linkedData = otherAgent._linkedData->clone();
|
_linkedData = otherAgent._linkedData->clone();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue