|
@@ -48,6 +48,7 @@
|
|
|
#include "core/mem_func.hpp"
|
|
|
#include "smallmap_gui.h"
|
|
|
#include "genworld.h"
|
|
|
#include "gui.h"
|
|
|
|
|
|
#include "table/strings.h"
|
|
|
#include "table/build_industry.h"
|
|
@@ -4349,21 +4350,14 @@ static uint16 SanitizeSpriteOffset(uint1
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/* Action 0x05 */
|
|
|
static void GraphicsNew(ByteReader *buf)
|
|
|
{
|
|
|
/* <05> <graphics-type> <num-sprites> <other data...>
|
|
|
*
|
|
|
* B graphics-type What set of graphics the sprites define.
|
|
|
* E num-sprites How many sprites are in this set?
|
|
|
* V other data Graphics type specific data. Currently unused. */
|
|
|
/* TODO */
|
|
|
|
|
|
|
|
|
/** The type of action 5 type. */
|
|
|
enum Action5BlockType {
|
|
|
A5BLOCK_FIXED, ///< Only allow replacing a whole block of sprites. (TTDP compatible)
|
|
|
A5BLOCK_ALLOW_OFFSET, ///< Allow replacing any subset by specifiing an offset.
|
|
|
A5BLOCK_INVALID, ///< unknown/not-implemented type
|
|
|
};
|
|
|
/** Information about a single action 5 type. */
|
|
|
struct Action5Type {
|
|
|
Action5BlockType block_type; ///< How is this Action5 type processed?
|
|
|
SpriteID sprite_base; ///< Load the sprites starting from this sprite.
|
|
@@ -4372,7 +4366,8 @@ static void GraphicsNew(ByteReader *buf)
|
|
|
const char *name; ///< Name for error messages.
|
|
|
};
|
|
|
|
|
|
static const Action5Type action5_types[] = {
|
|
|
/** The information about action 5 types. */
|
|
|
static const Action5Type _action5_types[] = {
|
|
|
/* Note: min_sprites should not be changed. Therefore these constants are directly here and not in sprites.h */
|
|
|
/* 0x00 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x00" },
|
|
|
/* 0x01 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x01" },
|
|
@@ -4399,15 +4394,25 @@ static void GraphicsNew(ByteReader *buf)
|
|
|
/* 0x16 */ { A5BLOCK_ALLOW_OFFSET, SPR_AIRPORT_PREVIEW_BASE, 1, SPR_AIRPORT_PREVIEW_COUNT, "Airport preview graphics" },
|
|
|
};
|
|
|
|
|
|
/* Action 0x05 */
|
|
|
static void GraphicsNew(ByteReader *buf)
|
|
|
{
|
|
|
/* <05> <graphics-type> <num-sprites> <other data...>
|
|
|
*
|
|
|
* B graphics-type What set of graphics the sprites define.
|
|
|
* E num-sprites How many sprites are in this set?
|
|
|
* V other data Graphics type specific data. Currently unused. */
|
|
|
/* TODO */
|
|
|
|
|
|
uint8 type = buf->ReadByte();
|
|
|
uint16 num = buf->ReadExtendedByte();
|
|
|
uint16 offset = HasBit(type, 7) ? buf->ReadExtendedByte() : 0;
|
|
|
ClrBit(type, 7); // Clear the high bit as that only indicates whether there is an offset.
|
|
|
|
|
|
if ((type == 0x0D) && (num == 10) && _cur_grffile->is_ottdfile) {
|
|
|
/* Special not-TTDP-compatible case used in openttd(d/w).grf
|
|
|
/* Special not-TTDP-compatible case used in openttd.grf
|
|
|
* Missing shore sprites and initialisation of SPR_SHORE_BASE */
|
|
|
grfmsg(2, "GraphicsNew: Loading 10 missing shore sprites from openttd(d/w).grf.");
|
|
|
grfmsg(2, "GraphicsNew: Loading 10 missing shore sprites from extra grf.");
|
|
|
LoadNextSprite(SPR_SHORE_BASE + 0, _file_index, _nfo_line++); // SLOPE_STEEP_S
|
|
|
LoadNextSprite(SPR_SHORE_BASE + 5, _file_index, _nfo_line++); // SLOPE_STEEP_W
|
|
|
LoadNextSprite(SPR_SHORE_BASE + 7, _file_index, _nfo_line++); // SLOPE_WSE
|
|
@@ -4423,13 +4428,13 @@ static void GraphicsNew(ByteReader *buf)
|
|
|
}
|
|
|
|
|
|
/* Supported type? */
|
|
|
if ((type >= lengthof(action5_types)) || (action5_types[type].block_type == A5BLOCK_INVALID)) {
|
|
|
if ((type >= lengthof(_action5_types)) || (_action5_types[type].block_type == A5BLOCK_INVALID)) {
|
|
|
grfmsg(2, "GraphicsNew: Custom graphics (type 0x%02X) sprite block of length %u (unimplemented, ignoring)", type, num);
|
|
|
_skip_sprites = num;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const Action5Type *action5_type = &action5_types[type];
|
|
|
const Action5Type *action5_type = &_action5_types[type];
|
|
|
|
|
|
/* Ignore offset if not allowed */
|
|
|
if ((action5_type->block_type != A5BLOCK_ALLOW_OFFSET) && (offset != 0)) {
|
|
@@ -4475,6 +4480,35 @@ static void SkipAct5(ByteReader *buf)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Check whether we are (obviously) missing some of the extra
|
|
|
* (Action 0x05) sprites that we like to use.
|
|
|
* When missing sprites are found a warning will be shown.
|
|
|
*/
|
|
|
void CheckForMissingSprites()
|
|
|
{
|
|
|
/* Don't break out quickly, but allow to check the other
|
|
|
* sprites as well, so we can give the best information. */
|
|
|
bool missing = false;
|
|
|
for (uint8 i = 0; i < lengthof(_action5_types); i++) {
|
|
|
const Action5Type *type = &_action5_types[i];
|
|
|
if (type->block_type == A5BLOCK_INVALID) continue;
|
|
|
|
|
|
for (uint j = 0; j < type->max_sprites; j++) {
|
|
|
if (!SpriteExists(type->sprite_base + j)) {
|
|
|
DEBUG(grf, 0, "%s sprites are missing", type->name);
|
|
|
missing = true;
|
|
|
/* No need to log more of the same. */
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (missing) {
|
|
|
ShowErrorMessage(STR_NEWGRF_ERROR_MISSING_SPRITES, INVALID_STRING_ID, WL_CRITICAL);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Reads a variable common to VarAction2 and Action7/9/D.
|
|
|
*
|
|
|
* Returns VarAction2 variable 'param' resp. Action7/9/D variable '0x80 + param'.
|