|
|
/* $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 animated_tile.cpp Everything related to animated tiles. */
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
#include "core/alloc_func.hpp"
|
|
|
#include "core/smallvec_type.hpp"
|
|
|
#include "tile_cmd.h"
|
|
|
#include "viewport_func.h"
|
|
|
#include "framerate_type.h"
|
|
|
|
|
|
#include "safeguards.h"
|
|
|
|
|
|
/** The table/list with animated tiles. */
|
|
|
SmallVector<TileIndex, 256> _animated_tiles;
|
|
|
std::vector<TileIndex> _animated_tiles;
|
|
|
|
|
|
/**
|
|
|
* Removes the given tile from the animated tile table.
|
|
|
* @param tile the tile to remove
|
|
|
*/
|
|
|
void DeleteAnimatedTile(TileIndex tile)
|
|
|
{
|
|
|
auto to_remove = std::find(_animated_tiles.begin(), _animated_tiles.end(), tile);
|
|
|
if (to_remove != _animated_tiles.end()) {
|
|
|
/* The order of the remaining elements must stay the same, otherwise the animation loop may miss a tile. */
|
|
|
_animated_tiles.erase(to_remove);
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Add the given tile to the animated tile table (if it does not exist
|
|
|
* on that table yet). Also increases the size of the table if necessary.
|
|
|
* @param tile the tile to make animated
|
|
|
*/
|
|
|
void AddAnimatedTile(TileIndex tile)
|
|
|
{
|
|
|
MarkTileDirtyByTile(tile);
|
|
|
include(_animated_tiles, tile);
|