Fixed layer names not being saved/loaded or copied

This commit is contained in:
Michaël Lemaire 2013-11-17 22:47:27 +01:00
parent 9e6838f733
commit 541f1e065f
6 changed files with 19 additions and 5 deletions

View file

@ -24,7 +24,7 @@ BaseDefinition::~BaseDefinition()
}
}
void BaseDefinition::setName(QString name)
void BaseDefinition::setName(const QString &name)
{
this->name = name;
}

View file

@ -26,7 +26,7 @@ public:
virtual void validate();
inline const QString& getName() const {return name;}
virtual void setName(QString name);
virtual void setName(const QString &name);
virtual Scenery* getScenery();

View file

@ -40,6 +40,8 @@ CloudLayerDefinition* CloudLayerDefinition::newCopy(BaseDefinition* parent) cons
void CloudLayerDefinition::save(PackStream* stream) const
{
BaseDefinition::save(stream);
int clouds_type = (int)type;
stream->write(&clouds_type);
@ -62,6 +64,8 @@ void CloudLayerDefinition::save(PackStream* stream) const
void CloudLayerDefinition::load(PackStream* stream)
{
BaseDefinition::load(stream);
int clouds_type;
stream->read(&clouds_type);
@ -87,6 +91,8 @@ void CloudLayerDefinition::load(PackStream* stream)
void CloudLayerDefinition::copy(BaseDefinition* _destination) const
{
BaseDefinition::copy(_destination);
CloudLayerDefinition* destination = (CloudLayerDefinition*)_destination;
destination->type = type;

View file

@ -20,6 +20,7 @@ void CloudsDefinition::applyPreset(CloudsPreset preset)
{
CloudLayerDefinition* layer = new CloudLayerDefinition(this);
layer->applyPreset(CloudLayerDefinition::CLOUDS_LAYER_PRESET_CIRRUS);
layer->setName("Cirrus");
addLayer(layer);
}
}

View file

@ -15,10 +15,9 @@ Layers::~Layers()
void Layers::copy(BaseDefinition* destination_) const
{
Layers* destination = (Layers*)destination_;
BaseDefinition::copy(destination_);
// don't call overridden method, it will copy again the children
// FIXME ... but the definition name (and other future attributes) is not copied
Layers* destination = (Layers*)destination_;
destination->clear();

View file

@ -26,6 +26,8 @@ TextureLayerDefinition::~TextureLayerDefinition()
void TextureLayerDefinition::validate()
{
BaseDefinition::validate();
if (displacement_scaling < 0.000001)
{
displacement_scaling = 0.000001;
@ -55,6 +57,8 @@ void TextureLayerDefinition::validate()
void TextureLayerDefinition::copy(BaseDefinition *_destination) const
{
BaseDefinition::copy(_destination);
TextureLayerDefinition* destination = (TextureLayerDefinition*)_destination;
terrain_zone->copy(destination->terrain_zone);
@ -70,6 +74,8 @@ void TextureLayerDefinition::copy(BaseDefinition *_destination) const
void TextureLayerDefinition::save(PackStream* stream) const
{
BaseDefinition::save(stream);
terrain_zone->save(stream);
stream->write(&displacement_scaling);
stream->write(&displacement_height);
@ -82,6 +88,8 @@ void TextureLayerDefinition::save(PackStream* stream) const
void TextureLayerDefinition::load(PackStream* stream)
{
BaseDefinition::load(stream);
terrain_zone->load(stream);
stream->read(&displacement_scaling);
stream->read(&displacement_height);