From 90e74e513393e0dfef11cbc0496b3bb9dc3d6c8a Mon Sep 17 00:00:00 2001 From: andreja6 Date: Sun, 21 Oct 2018 16:11:31 -0700 Subject: [PATCH] Duplicate works! --- Instance.cpp | 4 ++-- Instance.h | 2 +- PhysicalInstance.cpp | 2 +- main.cpp | 4 +--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Instance.cpp b/Instance.cpp index e7d400f..e7f3c39 100644 --- a/Instance.cpp +++ b/Instance.cpp @@ -16,9 +16,9 @@ Instance::Instance(void) Instance::Instance(const Instance &oinst) { - parent = oinst.parent; + setParent(oinst.parent); name = oinst.name; - className = "BaseInstance"; + className = oinst.className; } void Instance::render(RenderDevice* rd) diff --git a/Instance.h b/Instance.h index 09dff67..b8aea00 100644 --- a/Instance.h +++ b/Instance.h @@ -18,7 +18,7 @@ public: void addChild(Instance*); void removeChild(Instance*); Instance* getParent(); - Instance* clone() const { return new Instance(*this); } + virtual Instance* clone() const { return new Instance(*this); } protected: std::string className; Instance* parent; // Another pointer. diff --git a/PhysicalInstance.cpp b/PhysicalInstance.cpp index 85ceb6e..542cef3 100644 --- a/PhysicalInstance.cpp +++ b/PhysicalInstance.cpp @@ -28,7 +28,7 @@ PhysicalInstance::PhysicalInstance(const PhysicalInstance &oinst) name = oinst.name; className = "Part"; canCollide = oinst.canCollide; - + setParent(oinst.parent); anchored = oinst.anchored; size = oinst.size; setCFrame(oinst.cFrame); diff --git a/main.cpp b/main.cpp index 2734dcb..485c953 100644 --- a/main.cpp +++ b/main.cpp @@ -252,9 +252,7 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button) std::vector newinst; for(size_t i = 0; i < selectedInstances.size(); i++) { - Instance* inst = selectedInstances.at(i)->clone(); - newinst.push_back(inst); - inst->setParent(selectedInstances.at(i)->getParent()); + newinst.push_back(selectedInstances.at(i)->clone()); } selectedInstances = newinst; }