Added thing reconstruct
This commit is contained in:
parent
31c725b0ca
commit
26be4557c5
@ -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));
|
||||
|
16
Thing.cpp
16
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) {
|
||||
|
7
Thing.h
7
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user