From d48fbc477e5054cc18fad4a612610429d6dc7554 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 27 Feb 2010 22:41:30 +0000 Subject: [PATCH] Storing trees and buildings separately is pointless --- src/Map.cpp | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/Map.cpp b/src/Map.cpp index f1a4126..3273e86 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -124,8 +124,7 @@ private: // TODO: Better to use a boost::variant here? TrackNodePtr track; // Track at this location, if any IStationPtr station; // Station on this tile, if any - ISceneryPtr building; // Building on this tile, if any - ISceneryPtr tree; // Tree, if any + ISceneryPtr scenery; // Scenery, if any } *tiles; // Vertices on the terrain @@ -272,11 +271,8 @@ void Map::eraseTile(int x, int y) tileAt((*it).x, (*it).y).track.reset(); } - if (tile.building) - tile.building.reset(); - - if (tile.tree) - tile.tree.reset(); + if (tile.scenery) + tile.scenery.reset(); } void Map::setTrackAt(const Point& aPoint, ITrackSegmentPtr aTrack) @@ -781,13 +777,9 @@ void Map::renderSector(IGraphicsPtr aContext, int id, && shouldDrawGridLines) drawStartLocation(); - // Draw any buildings - if (tile.building) - tile.building->render(); - - // Draw any trees - if (tile.tree) - tile.tree->render(); + // Draw any scenery + if (tile.scenery) + tile.scenery->render(); } } } @@ -1025,7 +1017,7 @@ void Map::placeBuilding(Point point, ISceneryPtr building) if (tileAt(point).track) warn() << "Cannot place building on track"; else { - tileAt(point).building = building; + tileAt(point).scenery = building; building->setPosition(static_cast(point.x), heightAt(point.x, point.y), static_cast(point.y)); @@ -1037,7 +1029,7 @@ void Map::addScenery(Point where, ISceneryPtr s) if (tileAt(where.x, where.y).track) warn() << "Cannot place scenery on track"; else { - tileAt(where.x, where.y).tree = s; + tileAt(where.x, where.y).scenery = s; s->setPosition(static_cast(where.x), heightAt(where.x, where.y), static_cast(where.y)); @@ -1252,13 +1244,8 @@ void Map::save() useful = true; } - if (tile.building) { - tileXml.addChild(tile.building->toXml()); - useful = true; - } - - if (tile.tree) { - tileXml.addChild(tile.tree->toXml()); + if (tile.scenery) { + tileXml.addChild(tile.scenery->toXml()); useful = true; } -- 2.39.2