Mercurial > fife-parpg
diff engine/core/model/structures/layer.cpp @ 6:61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
author | jasoka@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 05 Jul 2008 09:14:21 +0000 |
parents | 4a0efb7baf70 |
children | 90005975cdbb |
line wrap: on
line diff
--- a/engine/core/model/structures/layer.cpp Fri Jul 04 19:02:53 2008 +0000 +++ b/engine/core/model/structures/layer.cpp Sat Jul 05 09:14:21 2008 +0000 @@ -119,35 +119,39 @@ } void Layer::getMinMaxCoordinates(ModelCoordinate& min, ModelCoordinate& max, const Layer* layer) const { - - if(layer == 0) { + if (!layer) { layer = this; } - min = m_instances.front()->getLocationRef().getLayerCoordinates(layer); - max = min; - - for(std::vector<Instance*>::const_iterator i = m_instances.begin(); - i != m_instances.end(); - ++i) { - - ModelCoordinate coord = (*i)->getLocationRef().getLayerCoordinates(layer); - - if(coord.x < min.x) { - min.x = coord.x; + bool first_found = false; + for (std::vector<Instance*>::const_iterator i = m_instances.begin(); i != m_instances.end(); ++i) { + if (!first_found) { + min = m_instances.front()->getLocationRef().getLayerCoordinates(layer); + max = min; + first_found = true; + } else { + ModelCoordinate coord = (*i)->getLocationRef().getLayerCoordinates(layer); + + if(coord.x < min.x) { + min.x = coord.x; + } + + if(coord.x > max.x) { + max.x = coord.x; + } + + if(coord.y < min.y) { + min.y = coord.y; + } + + if(coord.y > max.y) { + max.y = coord.y; + } } - - if(coord.x > max.x) { - max.x = coord.x; - } - - if(coord.y < min.y) { - min.y = coord.y; - } - - if(coord.y > max.y) { - max.y = coord.y; - } + } + if (!first_found) { + min = ModelCoordinate(); + max = min; } }