diff --git a/Participants/SiteServer.cpp b/Participants/SiteServer.cpp index bfe1c2d..5dc6361 100644 --- a/Participants/SiteServer.cpp +++ b/Participants/SiteServer.cpp @@ -72,7 +72,8 @@ void SiteServer::Process(Participant* sender, NetworkIdMsg* msg) {} void SiteServer::Process(Participant* sender, ThingMsg* msg) { Thing* thing = sender->Get(msg->thingId); if (thing == nullptr) - new Thing(sender, (Thing::Type)msg->thingType, msg->thingId); + // new Thing(sender, (Thing::Type)msg->thingType, msg->thingId); + Thing::Reconstruct(sender, msg->thingType, msg->thingId); if (msg->parentId != 0) { thing->SetParent(Get(msg->parentId)); diff --git a/Thing.cpp b/Thing.cpp index 0807295..e14a2bc 100644 --- a/Thing.cpp +++ b/Thing.cpp @@ -24,12 +24,12 @@ namespace RoboidControl { // : Thing(IsolatedParticipant::Isolated(), thingType) {} Thing::Thing(Participant* owner, - unsigned char thingType, - unsigned char thingId) { + unsigned char thingType) { + // unsigned char thingId) { if (owner == nullptr) owner = IsolatedParticipant::Isolated(); this->owner = owner; - this->id = thingId; + // this->id = thingId; this->type = thingType; this->position = Spherical::zero; @@ -47,11 +47,17 @@ Thing::Thing(Participant* owner, this->owner->Add(this, true); } -Thing::Thing(Thing* parent, unsigned char thingType, unsigned char thingId) - : Thing(parent->owner, thingType, thingId) { +Thing::Thing(Thing* parent, unsigned char thingType) //, unsigned char thingId) + : Thing(parent->owner, thingType) { //}, thingId) { this->SetParent(parent); } +Thing Thing::Reconstruct(Participant* owner, unsigned char thingType, unsigned char thingId) { + Thing thing = Thing(owner, thingType); + thing.id = thingId; + return thing; +} + #pragma endregion Init void Thing::SetName(const char* name) { diff --git a/Thing.h b/Thing.h index 536d050..0827886 100644 --- a/Thing.h +++ b/Thing.h @@ -51,8 +51,8 @@ class Thing { /// @param thingId The ID of the thing, leave out or set to zero to generate /// an ID Thing(Participant* owner = nullptr, - unsigned char thingType = Type::Undetermined, - unsigned char thingId = 0); + unsigned char thingType = Type::Undetermined); + //unsigned char thingId = 0); /// @brief Create a new child thing /// @param parent The parent thing @@ -60,8 +60,9 @@ class Thing { /// @param thingId The ID of the thing, leave out or set to zero to generate /// an ID /// @note The owner will be the same as the owner of the parent thing - Thing(Thing* parent, unsigned char thingType = 0, unsigned char thingId = 0); + Thing(Thing* parent, unsigned char thingType = 0); //, unsigned char thingId = 0); + static Thing Reconstruct(Participant* owner, unsigned char thingType, unsigned char thingId); #pragma endregion Init public: