OpenTTD Source
20241108-master-g80f628063a
|
Reading graphics data from (New)GRF files. More...
#include "../stdafx.h"
#include "../gfx_func.h"
#include "../debug.h"
#include "../settings_type.h"
#include "../strings_func.h"
#include "table/strings.h"
#include "../error.h"
#include "../core/math_func.hpp"
#include "../core/alloc_type.hpp"
#include "../core/bitmath_func.hpp"
#include "../spritecache.h"
#include "grf.hpp"
#include "../safeguards.h"
Go to the source code of this file.
Functions | |
static bool | WarnCorruptSprite (const SpriteFile &file, size_t file_pos, int line) |
We found a corrupted sprite. More... | |
bool | DecodeSingleSprite (SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, int64_t num, uint8_t type, ZoomLevel zoom_lvl, uint8_t colour_fmt, uint8_t container_format) |
Decode the image data of a single sprite. More... | |
uint8_t | LoadSpriteV1 (SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp) |
uint8_t | LoadSpriteV2 (SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint8_t control_flags) |
Variables | |
const uint8_t | _palmap_w2d [] |
Reading graphics data from (New)GRF files.
Definition in file grf.cpp.
bool DecodeSingleSprite | ( | SpriteLoader::Sprite * | sprite, |
SpriteFile & | file, | ||
size_t | file_pos, | ||
SpriteType | sprite_type, | ||
int64_t | num, | ||
uint8_t | type, | ||
ZoomLevel | zoom_lvl, | ||
uint8_t | colour_fmt, | ||
uint8_t | container_format | ||
) |
Decode the image data of a single sprite.
[in,out] | sprite | Filled with the sprite image data. |
file | The file with the sprite data. | |
file_pos | File position. | |
sprite_type | Type of the sprite we're decoding. | |
num | Size of the decompressed sprite. | |
type | Type of the encoded sprite. | |
zoom_lvl | Requested zoom level. | |
colour_fmt | Colour format of the sprite. | |
container_format | Container format of the GRF this sprite is in. |
Definition at line 60 of file grf.cpp.
References SpriteLoader::Sprite::AllocateData(), SpriteLoader::Sprite::height, RandomAccessFile::ReadByte(), SCC_ALPHA, SCC_PAL, SCC_RGB, WarnCorruptSprite(), and SpriteLoader::Sprite::width.
|
static |
We found a corrupted sprite.
This means that the sprite itself contains invalid data or is too small for the given dimensions.
file_slot | the file the errored sprite is in |
file_pos | the location in the file of the errored sprite |
line | the line where the error occurs. |
Definition at line 35 of file grf.cpp.
References Debug, RandomAccessFile::GetSimplifiedFilename(), INVALID_STRING_ID, SetDParamStr(), ShowErrorMessage(), and WL_ERROR.
Referenced by DecodeSingleSprite().