OpenTTD Source: src/animated_tile_map.h Source File

OpenTTD Source 15.0-beta1

animated_tile_map.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
10#ifndef ANIMATED_TILE_MAP_H
11#define ANIMATED_TILE_MAP_H
12
13#include "core/bitmath_func.hpp"
14#include "map_func.h"
15
19 enum class AnimatedTileState : uint8_t {
20 None = 0,
21 Deleted = 1,
22 Animated = 3,
23};
24
30 inline AnimatedTileState GetAnimatedTileState(Tile t)
31{
32 return static_cast<AnimatedTileState>(GB(t.m6(), 0, 2));
33}
34
39 inline void SetAnimatedTileState(Tile t, AnimatedTileState state)
40{
41 SB(t.m6(), 0, 2, to_underlying(state));
42}
43
44#endif /* ANIMATED_TILE_MAP_H */
AnimatedTileState
AnimatedTileState
Animation state of a possibly-animated tile.
Definition animated_tile_map.h:19
AnimatedTileState::Animated
@ Animated
Tile is animated.
AnimatedTileState::Deleted
@ Deleted
Tile was animated but should be removed.
AnimatedTileState::None
@ None
Tile is not animated.
SetAnimatedTileState
void SetAnimatedTileState(Tile t, AnimatedTileState state)
Set the animated state of a tile.
Definition animated_tile_map.h:39
GetAnimatedTileState
AnimatedTileState GetAnimatedTileState(Tile t)
Get the animated state of a tile.
Definition animated_tile_map.h:30
bitmath_func.hpp
Functions related to bit mathematics.
SB
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
Definition bitmath_func.hpp:58
GB
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Definition bitmath_func.hpp:32
Tile
Wrapper class to abstract away the way the tiles are stored.
Definition map_func.h:25
Tile::m6
debug_inline uint8_t & m6()
General purpose.
Definition map_func.h:173
to_underlying
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Definition enum_type.hpp:15
map_func.h
Functions related to maps.