OpenTTD Source 20250714-master-g67e56391c7
spritecache_internal.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 SPRITECACHE_INTERNAL_H
11#define SPRITECACHE_INTERNAL_H
12
13#include "core/math_func.hpp"
14#include "gfx_type.h"
16
17#include "table/sprites.h"
18
19/* These declarations are internal to spritecache but need to be exposed for unit-tests. */
20
22 std::unique_ptr<std::byte[]> ptr;
23 size_t file_pos = 0;
24 SpriteFile *file = nullptr;
25 uint32_t length;
26 uint32_t id = 0;
27 uint32_t lru = 0;
29 bool warned = false;
30 uint8_t control_flags = 0;
31
32 void ClearSpriteData();
33};
34
35inline bool IsMapgenSpriteID(SpriteID sprite)
36{
37 return IsInsideMM(sprite, SPR_MAPGEN_BEGIN, SPR_MAPGEN_END);
38}
39
40SpriteCache *AllocateSpriteCache(uint index);
41
42#endif /* SPRITECACHE_INTERNAL_H */
RandomAccessFile with some extra information specific for sprite files.
Types related to the graphics and/or input devices.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
SpriteType
Types of sprites that might be loaded.
Definition gfx_type.h:352
@ Invalid
Pseudosprite or other unusable sprite, used only internally.
Integer math functions.
constexpr bool IsInsideMM(const size_t x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Base for loading sprites.
This file contains all sprite-related enums and defines.
uint8_t control_flags
Control flags, see SpriteCacheCtrlFlags.
uint32_t length
Length of sprite data.
bool warned
True iff the user has been warned about incorrect use of this sprite.
SpriteType type
In some cases a single sprite is misused by two NewGRFs. Once as real sprite and once as recolour spr...
SpriteFile * file
The file the sprite in this entry can be found in.