Skip to content

Commit

Permalink
Fixed issue with map templates not getting the same plane set as thei…
Browse files Browse the repository at this point in the history
…r world
  • Loading branch information
Andrettin committed Dec 22, 2020
1 parent 5a26f47 commit 8e56694
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
16 changes: 5 additions & 11 deletions src/map/map_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void map_template::ProcessConfigData(const CConfigData *config_data)
this->plane = plane;
} else if (key == "world") {
wyrmgus::world *world = world::get(value);
this->set_world(world);
this->world = world;
} else if (key == "terrain_file") {
this->terrain_file = value;
} else if (key == "overlay_terrain_file") {
Expand Down Expand Up @@ -324,6 +324,10 @@ void map_template::check() const

void map_template::initialize()
{
if (this->plane == nullptr && this->world != nullptr) {
this->plane = this->world->get_plane();
}

if (this->get_subtemplate_top_left_pos().x() == -1 && this->get_subtemplate_top_left_pos().y() == -1 && this->get_subtemplate_center_pos().x() == -1 && this->get_subtemplate_center_pos().y() == -1) {
const QPoint subtemplate_offset = size::to_point(this->get_applied_size()) - QPoint(1, 1) / 2;
this->subtemplate_top_left_pos = this->get_subtemplate_center_pos() - subtemplate_offset;
Expand Down Expand Up @@ -2076,16 +2080,6 @@ QSize map_template::get_applied_size() const
return applied_size;
}

void map_template::set_world(wyrmgus::world *world)
{
if (world == this->get_world()) {
return;
}

this->world = world;
this->plane = this->world->get_plane();
}

void map_template::set_terrain_file(const std::filesystem::path &filepath)
{
if (filepath == this->get_terrain_file()) {
Expand Down
4 changes: 1 addition & 3 deletions src/map/map_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class map_template final : public named_data_entry, public data_type<map_templat
Q_PROPERTY(QGeoCoordinate min_subtemplate_geocoordinate MEMBER min_subtemplate_geocoordinate)
Q_PROPERTY(QGeoCoordinate max_subtemplate_geocoordinate MEMBER max_subtemplate_geocoordinate)
Q_PROPERTY(wyrmgus::plane* plane MEMBER plane)
Q_PROPERTY(wyrmgus::world* world MEMBER world WRITE set_world)
Q_PROPERTY(wyrmgus::world* world MEMBER world)
Q_PROPERTY(wyrmgus::map_template* main_template READ get_main_template WRITE set_main_template)
Q_PROPERTY(QString terrain_file READ get_terrain_file_qstring)
Q_PROPERTY(QString overlay_terrain_file READ get_overlay_terrain_file_qstring)
Expand Down Expand Up @@ -380,8 +380,6 @@ class map_template final : public named_data_entry, public data_type<map_templat
return this->world;
}

void set_world(wyrmgus::world *world);

map_template *get_main_template() const
{
return this->main_template;
Expand Down

0 comments on commit 8e56694

Please sign in to comment.