summaryrefslogtreecommitdiff
path: root/src/tilearea_type.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-01-04 18:05:14 +0000
committerrubidium <rubidium@openttd.org>2010-01-04 18:05:14 +0000
commit8b88bb0c9bf1072881b4111a339eb6781fdb80bc (patch)
treea7c088ba37027beb12e51e672ff116e14b174c24 /src/tilearea_type.h
parent02a297669a5353518d51f6f4d9641114e557aede (diff)
downloadopenttd-8b88bb0c9bf1072881b4111a339eb6781fdb80bc.tar.xz
(svn r18714) -Codechange: move the TileArea struct to it's own header
Diffstat (limited to 'src/tilearea_type.h')
-rw-r--r--src/tilearea_type.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/tilearea_type.h b/src/tilearea_type.h
new file mode 100644
index 000000000..8bac2fbbf
--- /dev/null
+++ b/src/tilearea_type.h
@@ -0,0 +1,58 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file tilearea_type.h Type for storing the 'area' of something uses on the map. */
+
+#ifndef TILEAREA_TYPE_H
+#define TILEAREA_TYPE_H
+
+#include "tile_type.h"
+
+/** Represents the covered area of e.g. a rail station */
+struct TileArea {
+ /** Just construct this tile area */
+ TileArea() {}
+
+ /**
+ * Construct this tile area with some set values
+ * @param tile the base tile
+ * @param w the width
+ * @param h the height
+ */
+ TileArea(TileIndex tile, uint8 w, uint8 h) : tile(tile), w(w), h(h) {}
+
+ /**
+ * Construct this tile area based on two points.
+ * @param start the start of the area
+ * @param end the end of the area
+ */
+ TileArea(TileIndex start, TileIndex end);
+
+ TileIndex tile; ///< The base tile of the area
+ uint8 w; ///< The width of the area
+ uint8 h; ///< The height of the area
+
+ /**
+ * Add a single tile to a tile area; enlarge if needed.
+ * @param to_add The tile to add
+ */
+ void Add(TileIndex to_add);
+
+ /**
+ * Clears the 'tile area', i.e. make the tile invalid.
+ */
+ void Clear()
+ {
+ this->tile = INVALID_TILE;
+ this->w = 0;
+ this->h = 0;
+ }
+};
+
+#endif /* TILEAREA_TYPE_H */