summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorplanetmaker <planetmaker@openttd.org>2011-10-05 17:07:43 +0000
committerplanetmaker <planetmaker@openttd.org>2011-10-05 17:07:43 +0000
commit162b98faa5a0a72241e3519c41e283cee3155523 (patch)
tree26f24fd2e6f68dd4ba689cda714588e860212589 /src
parent8c4c616cfea90820d0b5099eb5d41737fe2ef658 (diff)
downloadopenttd-162b98faa5a0a72241e3519c41e283cee3155523.tar.xz
(svn r23004) -Feature [FS#4795]: Allow to use offsets for all types of action5 except sea shores
Diffstat (limited to 'src')
-rw-r--r--src/newgrf.cpp62
1 files changed, 27 insertions, 35 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index d71479585..37dc2587b 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -5265,28 +5265,28 @@ struct Action5Type {
/** 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" },
- /* 0x02 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x02" },
- /* 0x03 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x03" },
- /* 0x04 */ { A5BLOCK_FIXED, SPR_SIGNALS_BASE, 48, PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT, "Signal graphics" },
- /* 0x05 */ { A5BLOCK_FIXED, SPR_ELRAIL_BASE, 48, ELRAIL_SPRITE_COUNT, "Catenary graphics" },
- /* 0x06 */ { A5BLOCK_FIXED, SPR_SLOPES_BASE, 74, NORMAL_AND_HALFTILE_FOUNDATION_SPRITE_COUNT, "Foundation graphics" },
- /* 0x07 */ { A5BLOCK_INVALID, 0, 75, 0, "TTDP GUI graphics" }, // Not used by OTTD.
- /* 0x08 */ { A5BLOCK_FIXED, SPR_CANALS_BASE, 65, CANALS_SPRITE_COUNT, "Canal graphics" },
- /* 0x09 */ { A5BLOCK_FIXED, SPR_ONEWAY_BASE, 6, ONEWAY_SPRITE_COUNT, "One way road graphics" },
- /* 0x0A */ { A5BLOCK_FIXED, SPR_2CCMAP_BASE, 256, TWOCCMAP_SPRITE_COUNT, "2CC colour maps" },
- /* 0x0B */ { A5BLOCK_FIXED, SPR_TRAMWAY_BASE, 113, TRAMWAY_SPRITE_COUNT, "Tramway graphics" },
- /* 0x0C */ { A5BLOCK_INVALID, 0, 133, 0, "Snowy temperate tree" }, // Not yet used by OTTD.
- /* 0x0D */ { A5BLOCK_FIXED, SPR_SHORE_BASE, 16, SPR_SHORE_SPRITE_COUNT, "Shore graphics" },
- /* 0x0E */ { A5BLOCK_INVALID, 0, 0, 0, "New Signals graphics" }, // Not yet used by OTTD.
- /* 0x0F */ { A5BLOCK_FIXED, SPR_TRACKS_FOR_SLOPES_BASE, 12, TRACKS_FOR_SLOPES_SPRITE_COUNT, "Sloped rail track" },
- /* 0x10 */ { A5BLOCK_FIXED, SPR_AIRPORTX_BASE, 15, AIRPORTX_SPRITE_COUNT, "Airport graphics" },
- /* 0x11 */ { A5BLOCK_FIXED, SPR_ROADSTOP_BASE, 8, ROADSTOP_SPRITE_COUNT, "Road stop graphics" },
- /* 0x12 */ { A5BLOCK_FIXED, SPR_AQUEDUCT_BASE, 8, AQUEDUCT_SPRITE_COUNT, "Aqueduct graphics" },
- /* 0x13 */ { A5BLOCK_FIXED, SPR_AUTORAIL_BASE, 55, AUTORAIL_SPRITE_COUNT, "Autorail graphics" },
- /* 0x14 */ { A5BLOCK_ALLOW_OFFSET, SPR_FLAGS_BASE, 1, FLAGS_SPRITE_COUNT, "Flag graphics" },
- /* 0x15 */ { A5BLOCK_ALLOW_OFFSET, SPR_OPENTTD_BASE, 1, OPENTTD_SPRITE_COUNT, "OpenTTD GUI graphics" },
+ /* 0x00 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x00" },
+ /* 0x01 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x01" },
+ /* 0x02 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x02" },
+ /* 0x03 */ { A5BLOCK_INVALID, 0, 0, 0, "Type 0x03" },
+ /* 0x04 */ { A5BLOCK_ALLOW_OFFSET, SPR_SIGNALS_BASE, 1, PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT, "Signal graphics" },
+ /* 0x05 */ { A5BLOCK_ALLOW_OFFSET, SPR_ELRAIL_BASE, 1, ELRAIL_SPRITE_COUNT, "Catenary graphics" },
+ /* 0x06 */ { A5BLOCK_ALLOW_OFFSET, SPR_SLOPES_BASE, 1, NORMAL_AND_HALFTILE_FOUNDATION_SPRITE_COUNT, "Foundation graphics" },
+ /* 0x07 */ { A5BLOCK_INVALID, 0, 75, 0, "TTDP GUI graphics" }, // Not used by OTTD.
+ /* 0x08 */ { A5BLOCK_ALLOW_OFFSET, SPR_CANALS_BASE, 1, CANALS_SPRITE_COUNT, "Canal graphics" },
+ /* 0x09 */ { A5BLOCK_ALLOW_OFFSET, SPR_ONEWAY_BASE, 1, ONEWAY_SPRITE_COUNT, "One way road graphics" },
+ /* 0x0A */ { A5BLOCK_ALLOW_OFFSET, SPR_2CCMAP_BASE, 1, TWOCCMAP_SPRITE_COUNT, "2CC colour maps" },
+ /* 0x0B */ { A5BLOCK_ALLOW_OFFSET, SPR_TRAMWAY_BASE, 1, TRAMWAY_SPRITE_COUNT, "Tramway graphics" },
+ /* 0x0C */ { A5BLOCK_INVALID, 0, 133, 0, "Snowy temperate tree" }, // Not yet used by OTTD.
+ /* 0x0D */ { A5BLOCK_FIXED, SPR_SHORE_BASE, 16, SPR_SHORE_SPRITE_COUNT, "Shore graphics" },
+ /* 0x0E */ { A5BLOCK_INVALID, 0, 0, 0, "New Signals graphics" }, // Not yet used by OTTD.
+ /* 0x0F */ { A5BLOCK_ALLOW_OFFSET, SPR_TRACKS_FOR_SLOPES_BASE, 1, TRACKS_FOR_SLOPES_SPRITE_COUNT, "Sloped rail track" },
+ /* 0x10 */ { A5BLOCK_ALLOW_OFFSET, SPR_AIRPORTX_BASE, 1, AIRPORTX_SPRITE_COUNT, "Airport graphics" },
+ /* 0x11 */ { A5BLOCK_ALLOW_OFFSET, SPR_ROADSTOP_BASE, 1, ROADSTOP_SPRITE_COUNT, "Road stop graphics" },
+ /* 0x12 */ { A5BLOCK_ALLOW_OFFSET, SPR_AQUEDUCT_BASE, 1, AQUEDUCT_SPRITE_COUNT, "Aqueduct graphics" },
+ /* 0x13 */ { A5BLOCK_ALLOW_OFFSET, SPR_AUTORAIL_BASE, 1, AUTORAIL_SPRITE_COUNT, "Autorail graphics" },
+ /* 0x14 */ { A5BLOCK_ALLOW_OFFSET, SPR_FLAGS_BASE, 1, FLAGS_SPRITE_COUNT, "Flag graphics" },
+ /* 0x15 */ { A5BLOCK_ALLOW_OFFSET, SPR_OPENTTD_BASE, 1, OPENTTD_SPRITE_COUNT, "OpenTTD GUI graphics" },
/* 0x16 */ { A5BLOCK_ALLOW_OFFSET, SPR_AIRPORT_PREVIEW_BASE, 1, SPR_AIRPORT_PREVIEW_COUNT, "Airport preview graphics" },
};
@@ -5332,19 +5332,11 @@ static void GraphicsNew(ByteReader *buf)
const Action5Type *action5_type = &_action5_types[type];
- /* Ignore offset if not allowed */
- if ((action5_type->block_type != A5BLOCK_ALLOW_OFFSET) && (offset != 0)) {
- grfmsg(1, "GraphicsNew: %s (type 0x%02X) do not allow an <offset> field. Ignoring offset.", action5_type->name, type);
- offset = 0;
- }
-
- /* Ignore action5 if too few sprites are specified. (for TTDP compatibility)
- * This does not make sense, if <offset> is allowed */
- if ((action5_type->block_type == A5BLOCK_FIXED) && (num < action5_type->min_sprites)) {
- grfmsg(1, "GraphicsNew: %s (type 0x%02X) count must be at least %d. Only %d were specified. Skipping.", action5_type->name, type, action5_type->min_sprites, num);
- _cur.skip_sprites = num;
- return;
- }
+ /* Contrary to TTDP we allow always to specify too few sprites as we allow always an offset.
+ * Thus no check for the amount of sprites is needed (anymore).
+ * The only no-offset entry, shores, is handled above already.
+ * We'll assume that offsets are always allowed further down, thus assert on this */
+ assert(action5_type->block_type == A5BLOCK_ALLOW_OFFSET);
/* Load at most max_sprites sprites. Skip remaining sprites. (for compatibility with TTDP and future extentions) */
uint16 skip_num = SanitizeSpriteOffset(num, offset, action5_type->max_sprites, action5_type->name);