Mercurial > fife-parpg
comparison engine/core/model/structures/layer.cpp @ 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 |
comparison
equal
deleted
inserted
replaced
90:9855464762c1 | 91:e7b55b2b398f |
---|---|
61 Instance* Layer::createInstance(Object* object, const ModelCoordinate& p, const std::string& id) { | 61 Instance* Layer::createInstance(Object* object, const ModelCoordinate& p, const std::string& id) { |
62 ExactModelCoordinate emc(static_cast<double>(p.x), static_cast<double>(p.y), static_cast<double>(p.z)); | 62 ExactModelCoordinate emc(static_cast<double>(p.x), static_cast<double>(p.y), static_cast<double>(p.z)); |
63 return createInstance(object, emc, id); | 63 return createInstance(object, emc, id); |
64 } | 64 } |
65 | 65 |
66 Instance* Layer::createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id) { | 66 bool Layer::createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id) { |
67 Location l; | 67 Location l; |
68 l.setLayer(this); | 68 l.setLayer(this); |
69 l.setExactLayerCoordinates(p); | 69 l.setExactLayerCoordinates(p); |
70 | 70 |
71 if(id != "") { | 71 if(id != "") { |
88 m_changed = true; | 88 m_changed = true; |
89 return instance; | 89 return instance; |
90 } | 90 } |
91 | 91 |
92 bool Layer::addInstance(Instance* instance, const ExactModelCoordinate& p){ | 92 bool Layer::addInstance(Instance* instance, const ExactModelCoordinate& p){ |
93 if( !instance ) | 93 if( !instance ){ |
94 FL_ERR(_log, "Tried to add an instance to layer, but given instance is invalid"); | 94 FL_ERR(_log, "Tried to add an instance to layer, but given instance is invalid"); |
95 return false; | |
96 } | |
97 | |
95 Location l; | 98 Location l; |
96 l.setLayer(this); | 99 l.setLayer(this); |
97 l.setExactLayerCoordinates(p); | 100 l.setExactLayerCoordinates(p); |
98 std::string id = instance->getId(); | 101 std::string id = instance->getId(); |
99 | 102 |
112 while (i != m_changelisteners.end()) { | 115 while (i != m_changelisteners.end()) { |
113 (*i)->onInstanceCreate(this, instance); | 116 (*i)->onInstanceCreate(this, instance); |
114 ++i; | 117 ++i; |
115 } | 118 } |
116 m_changed = true; | 119 m_changed = true; |
117 return instance; | 120 return true; |
118 } | 121 } |
119 | 122 |
120 void Layer::deleteInstance(Instance* instance) { | 123 void Layer::deleteInstance(Instance* instance) { |
121 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin(); | 124 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin(); |
122 while (i != m_changelisteners.end()) { | 125 while (i != m_changelisteners.end()) { |