Mercurial > fife-parpg
changeset 91:e7b55b2b398f
Corrected Layer::addInstance() to return appropriate bool. Added the function to layer.i for swig
author | Sleek@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 19 Jul 2008 12:14:51 +0000 |
parents | 9855464762c1 |
children | 746df66978da |
files | engine/core/model/structures/layer.cpp engine/core/model/structures/layer.h engine/core/model/structures/layer.i |
diffstat | 3 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/engine/core/model/structures/layer.cpp Sat Jul 19 12:06:14 2008 +0000 +++ b/engine/core/model/structures/layer.cpp Sat Jul 19 12:14:51 2008 +0000 @@ -63,7 +63,7 @@ return createInstance(object, emc, id); } - Instance* Layer::createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id) { + bool Layer::createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id) { Location l; l.setLayer(this); l.setExactLayerCoordinates(p); @@ -90,8 +90,11 @@ } bool Layer::addInstance(Instance* instance, const ExactModelCoordinate& p){ - if( !instance ) + if( !instance ){ FL_ERR(_log, "Tried to add an instance to layer, but given instance is invalid"); + return false; + } + Location l; l.setLayer(this); l.setExactLayerCoordinates(p); @@ -114,7 +117,7 @@ ++i; } m_changed = true; - return instance; + return true; } void Layer::deleteInstance(Instance* instance) {
--- a/engine/core/model/structures/layer.h Sat Jul 19 12:06:14 2008 +0000 +++ b/engine/core/model/structures/layer.h Sat Jul 19 12:14:51 2008 +0000 @@ -135,7 +135,7 @@ /** Add a valid instance at a specific position. This is temporary. It will be moved to a higher level later so that we can ensure that each Instance only lives in one layer. */ - Instance* Layer::addInstance(Instance* instance, const ExactModelCoordinate& p); + bool addInstance(Instance* instance, const ExactModelCoordinate& p); /** Remove an instance from the layer */
--- a/engine/core/model/structures/layer.i Sat Jul 19 12:06:14 2008 +0000 +++ b/engine/core/model/structures/layer.i Sat Jul 19 12:14:51 2008 +0000 @@ -68,6 +68,7 @@ bool hasInstances() const; Instance* createInstance(Object* object, const ModelCoordinate& p, const std::string& id=""); Instance* createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id=""); + bool addInstance(Instance* instance, const ExactModelCoordinate& p); void deleteInstance(Instance* object); const std::vector<Instance*>& getInstances() const;