summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/data/halffndw.grfbin0 -> 21613 bytes
-rw-r--r--bin/data/halfselw.grfbin0 -> 2844 bytes
-rw-r--r--src/gfxinit.cpp18
-rw-r--r--src/landscape.cpp41
-rw-r--r--src/table/files.h2
-rw-r--r--src/table/landscape_sprite.h40
-rw-r--r--src/table/sprites.h17
7 files changed, 86 insertions, 32 deletions
diff --git a/bin/data/halffndw.grf b/bin/data/halffndw.grf
new file mode 100644
index 000000000..8fe4ad447
--- /dev/null
+++ b/bin/data/halffndw.grf
Binary files differ
diff --git a/bin/data/halfselw.grf b/bin/data/halfselw.grf
new file mode 100644
index 000000000..e80c14ea1
--- /dev/null
+++ b/bin/data/halfselw.grf
Binary files differ
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index cba9c5461..f5263aad4 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -28,11 +28,6 @@ struct FileList {
MD5File landscape[3]; ///< landscape specific grf files
};
-enum {
- SKIP = 0xFFFE,
- END = 0xFFFF
-};
-
#include "table/files.h"
#include "table/landscape_sprite.h"
@@ -49,6 +44,13 @@ static const SpriteID * const _slopes_spriteindexes[] = {
_slopes_spriteindexes_3,
};
+static const SpriteID * const _halftile_foundation_spriteindexes[] = {
+ _halftile_foundation_spriteindexes_0,
+ _halftile_foundation_spriteindexes_1,
+ _halftile_foundation_spriteindexes_2,
+ _halftile_foundation_spriteindexes_3,
+};
+
static uint LoadGrfFile(const char* filename, uint load_index, int file_index)
{
@@ -386,6 +388,12 @@ static void LoadSpriteTables()
load_index++; // SPR_EMPTY_BOUNDING_BOX
+ assert(load_index == SPR_HALFTILE_FOUNDATION_BASE);
+ LoadGrfIndexed("halffndw.grf", _halftile_foundation_spriteindexes[_opt.landscape], i++);
+
+ load_index = SPR_HALFTILE_SELECTION_BASE;
+ load_index += LoadGrfFile("halfselw.grf", load_index, i++);
+
assert(load_index == SPR_FLAGS_BASE);
load_index += LoadGrfFile("flags.grf", load_index, i++);
diff --git a/src/landscape.cpp b/src/landscape.cpp
index d4e25e703..ddb1d73a8 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -308,23 +308,28 @@ void DrawFoundation(TileInfo *ti, Foundation f)
{
if (!IsFoundation(f)) return;
- SpriteID sprite_base = SPR_SLOPES_VIRTUAL_BASE;
+ uint sprite_block = 0;
uint z;
Slope slope = GetFoundationSlope(ti->tile, &z);
- if (!HasFoundationNW(ti->tile, slope, z)) sprite_base += SPR_SLOPES_NO_FOUNDATION_NW_OFFSET;
- if (!HasFoundationNE(ti->tile, slope, z)) sprite_base += SPR_SLOPES_NO_FOUNDATION_NE_OFFSET;
+ /* Select the needed block of foundations sprites
+ * Block 0: Walls at NW and NE edge
+ * Block 1: Wall at NE edge
+ * Block 2: Wall at NW edge
+ * Block 3: No walls at NW or NE edge
+ */
+ if (!HasFoundationNW(ti->tile, slope, z)) sprite_block += 1;
+ if (!HasFoundationNE(ti->tile, slope, z)) sprite_block += 2;
- if (IsSteepSlope(ti->tileh)) {
- SpriteID lower_base;
+ /* Use the original slope sprites if NW and NE borders should be visible */
+ SpriteID leveled_base = (sprite_block == 0 ? (int)SPR_FOUNDATION_BASE : (SPR_SLOPES_VIRTUAL_BASE + sprite_block * SPR_TRKFOUND_BLOCK_SIZE));
+ SpriteID inclined_base = SPR_SLOPES_VIRTUAL_BASE + SPR_SLOPES_INCLINED_OFFSET + sprite_block * SPR_TRKFOUND_BLOCK_SIZE;
+ //SpriteID halftile_base = SPR_HALFTILE_FOUNDATION_BASE + sprite_block * SPR_HALFTILE_BLOCK_SIZE;
- /* Lower part of foundation
- * Use the original slope sprites if NW and NE borders should be visible
- */
- lower_base = sprite_base;
- if (lower_base == SPR_SLOPES_VIRTUAL_BASE) lower_base = SPR_FOUNDATION_BASE;
+ if (IsSteepSlope(ti->tileh)) {
+ /* Lower part of foundation */
AddSortableSpriteToDraw(
- lower_base + (ti->tileh & ~SLOPE_STEEP), PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z
+ leveled_base + (ti->tileh & ~SLOPE_STEEP), PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z
);
Corner highest_corner = GetHighestSlopeCorner(ti->tileh);
@@ -334,13 +339,13 @@ void DrawFoundation(TileInfo *ti, Foundation f)
/* inclined foundation */
byte inclined = highest_corner * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0);
- AddSortableSpriteToDraw(sprite_base + SPR_SLOPES_INCLINED_OFFSET + inclined, PAL_NONE, ti->x, ti->y, 16, 16, 1, ti->z);
+ AddSortableSpriteToDraw(inclined_base + inclined, PAL_NONE, ti->x, ti->y, 16, 16, 1, ti->z);
OffsetGroundSprite(31, 9);
} else if (f >= FOUNDATION_STEEP_HIGHER) {
/* three corners raised:
* Draw inclined foundations for both axes, that results in the needed image.
*/
- SpriteID upper = sprite_base + SPR_SLOPES_INCLINED_OFFSET + highest_corner * 2;
+ SpriteID upper = inclined_base + highest_corner * 2;
AddSortableSpriteToDraw(upper, PAL_NONE, ti->x, ti->y, 16, 16, 1, ti->z);
AddChildSpriteScreen(upper + 1, PAL_NONE, 31, 9);
@@ -351,18 +356,14 @@ void DrawFoundation(TileInfo *ti, Foundation f)
}
} else {
if (IsLeveledFoundation(f)) {
- /* leveled foundation
- * Use the original slope sprites if NW and NE borders should be visible
- */
- if (sprite_base == SPR_SLOPES_VIRTUAL_BASE) sprite_base = SPR_FOUNDATION_BASE;
-
- AddSortableSpriteToDraw(sprite_base + ti->tileh, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z);
+ /* leveled foundation */
+ AddSortableSpriteToDraw(leveled_base + ti->tileh, PAL_NONE, ti->x, ti->y, 16, 16, 7, ti->z);
OffsetGroundSprite(31, 1);
} else {
/* inclined foundation */
byte inclined = GetHighestSlopeCorner(ti->tileh) * 2 + (f == FOUNDATION_INCLINED_Y ? 1 : 0);
- AddSortableSpriteToDraw(sprite_base + SPR_SLOPES_INCLINED_OFFSET + inclined, PAL_NONE, ti->x, ti->y, 16, 16, 1, ti->z);
+ AddSortableSpriteToDraw(inclined_base + inclined, PAL_NONE, ti->x, ti->y, 16, 16, 1, ti->z);
OffsetGroundSprite(31, 9);
}
ti->z += ApplyFoundationToSlope(f, &ti->tileh);
diff --git a/src/table/files.h b/src/table/files.h
index 98888c8d3..3deba561a 100644
--- a/src/table/files.h
+++ b/src/table/files.h
@@ -65,5 +65,7 @@ static MD5File files_openttd[] = {
{ "group.grf", { 0xe8, 0x52, 0x5f, 0x1c, 0x3e, 0xf9, 0x91, 0x9d, 0x0f, 0x70, 0x8c, 0x8a, 0x21, 0xa4, 0xc7, 0x02 } },
{ "tramtrkw.grf", { 0x83, 0x0a, 0xf4, 0x9f, 0x29, 0x10, 0x48, 0xfd, 0x76, 0xe9, 0xda, 0xac, 0x5d, 0xa2, 0x30, 0x45 } },
{ "oneway.grf", { 0xbb, 0xc6, 0xa3, 0xb2, 0xb3, 0xa0, 0xc9, 0x3c, 0xc9, 0xee, 0x24, 0x7c, 0xb6, 0x51, 0x74, 0x63 } },
+ { "halffndw.grf", { 0xf2, 0x10, 0xe0, 0xc1, 0xa1, 0xdc, 0xb3, 0x6e, 0x3f, 0xce, 0xb8, 0x98, 0x1a, 0x08, 0xb0, 0x67 } },
+ { "halfselw.grf", { 0xf2, 0x12, 0x2e, 0x88, 0x58, 0x08, 0xc4, 0xa5, 0xbd, 0x91, 0xb3, 0xc2, 0x5b, 0x5a, 0xb9, 0xf4 } },
{ "flags.grf", { 0xa1, 0xd7, 0x72, 0x75, 0x0e, 0x81, 0x86, 0x0e, 0xc9, 0xcd, 0xc2, 0x57, 0xb2, 0x19, 0xe1, 0x0c } },
};
diff --git a/src/table/landscape_sprite.h b/src/table/landscape_sprite.h
index 88f5f48b1..49b650e47 100644
--- a/src/table/landscape_sprite.h
+++ b/src/table/landscape_sprite.h
@@ -1,5 +1,10 @@
/* $Id$ */
+enum {
+ SKIP = 0xFFFE,
+ END = 0xFFFF
+};
+
static const SpriteID _landscape_spriteindexes_1[] = {
0xF67, 0xF9F,
0xAAD, 0xAB0,
@@ -138,7 +143,7 @@ END
Skip first 3 sprites and only load the proper set */
static const SpriteID _slopes_spriteindexes_0[] = {
SKIP, 3,
- SPR_SLOPES_BASE, SPR_SLOPES_BASE + 73,
+ SPR_SLOPES_VIRTUAL_BASE + 15, SPR_SLOPES_VIRTUAL_BASE + 4 * SPR_TRKFOUND_BLOCK_SIZE,
END
};
@@ -146,7 +151,7 @@ static const SpriteID _slopes_spriteindexes_0[] = {
Skip first 79 sprites and only load the proper set */
static const SpriteID _slopes_spriteindexes_1[] = {
SKIP, 79,
- SPR_SLOPES_BASE, SPR_SLOPES_BASE + 73,
+ SPR_SLOPES_VIRTUAL_BASE + 15, SPR_SLOPES_VIRTUAL_BASE + 4 * SPR_TRKFOUND_BLOCK_SIZE,
END
};
@@ -154,7 +159,7 @@ static const SpriteID _slopes_spriteindexes_1[] = {
Skip first 155 sprites and only load the proper set */
static const SpriteID _slopes_spriteindexes_2[] = {
SKIP, 155,
- SPR_SLOPES_BASE, SPR_SLOPES_BASE + 73,
+ SPR_SLOPES_VIRTUAL_BASE + 15, SPR_SLOPES_VIRTUAL_BASE + 4 * SPR_TRKFOUND_BLOCK_SIZE,
END
};
@@ -162,6 +167,33 @@ static const SpriteID _slopes_spriteindexes_2[] = {
Skip first 231 sprites and only load the proper set */
static const SpriteID _slopes_spriteindexes_3[] = {
SKIP, 231,
- SPR_SLOPES_BASE, SPR_SLOPES_BASE + 73,
+ SPR_SLOPES_VIRTUAL_BASE + 15, SPR_SLOPES_VIRTUAL_BASE + 4 * SPR_TRKFOUND_BLOCK_SIZE,
+ END
+};
+
+/* Halftile foundation indexes for temperate climate */
+static const SpriteID _halftile_foundation_spriteindexes_0[] = {
+ SPR_HALFTILE_FOUNDATION_BASE, SPR_HALFTILE_FOUNDATION_BASE + 4 * SPR_HALFTILE_BLOCK_SIZE - 1,
+ END
+};
+
+/* Halftile foundation indexes for arctic climate */
+static const SpriteID _halftile_foundation_spriteindexes_1[] = {
+ SKIP, 16,
+ SPR_HALFTILE_FOUNDATION_BASE, SPR_HALFTILE_FOUNDATION_BASE + 4 * SPR_HALFTILE_BLOCK_SIZE - 1,
+ END
+};
+
+/* Halftile foundation indexes for tropic climate */
+static const SpriteID _halftile_foundation_spriteindexes_2[] = {
+ SKIP, 32,
+ SPR_HALFTILE_FOUNDATION_BASE, SPR_HALFTILE_FOUNDATION_BASE + 4 * SPR_HALFTILE_BLOCK_SIZE - 1,
+ END
+};
+
+/* Halftile foundation indexes for toyland climate */
+static const SpriteID _halftile_foundation_spriteindexes_3[] = {
+ SKIP, 48,
+ SPR_HALFTILE_FOUNDATION_BASE, SPR_HALFTILE_FOUNDATION_BASE + 4 * SPR_HALFTILE_BLOCK_SIZE - 1,
END
};
diff --git a/src/table/sprites.h b/src/table/sprites.h
index 787edccd7..ee9b6fa3f 100644
--- a/src/table/sprites.h
+++ b/src/table/sprites.h
@@ -54,8 +54,9 @@ enum Sprites {
SPR_SLOPES_BASE = SPR_CANALS_BASE + 70,
SPR_SLOPES_INCLINED_OFFSET = 15,
SPR_SLOPES_VIRTUAL_BASE = SPR_SLOPES_BASE - SPR_SLOPES_INCLINED_OFFSET, // The original foundations (see SPR_FOUNDATION_BASE below) are mapped before the additional foundations.
- SPR_SLOPES_NO_FOUNDATION_NW_OFFSET = 22, // no wall on the NW edge of the tile.
- SPR_SLOPES_NO_FOUNDATION_NE_OFFSET = 44, // no wall on the NE edge of the tile.
+ SPR_TRKFOUND_BLOCK_SIZE = 22, // The sprites in trkfoundw.grf are organized in blocks of 22.
+
+ /* between slopes and autorail are 4 unused sprites */
SPR_AUTORAIL_BASE = SPR_SLOPES_BASE + 78,
SPR_ELRAIL_BASE = SPR_AUTORAIL_BASE + 55,
@@ -179,8 +180,18 @@ enum Sprites {
/* Not really a sprite, but an empty bounding box. Used to construct bounding boxes, that help sorting the sprites, but do not have a sprite associated. */
SPR_EMPTY_BOUNDING_BOX = SPR_ONEWAY_BASE + 6,
+ /* Halftile foundations */
+ SPR_HALFTILE_FOUNDATION_BASE = SPR_EMPTY_BOUNDING_BOX + 1,
+ SPR_HALFTILE_BLOCK_SIZE = 4, // The sprites in halffndw.grf are organized in blocks of 4.
+
+ /* Halftile-selection sprites */
+ SPR_HALFTILE_SELECTION_BASE = SPR_HALFTILE_FOUNDATION_BASE + 4 * SPR_HALFTILE_BLOCK_SIZE,
+ SPR_HALFTILE_SELECTION_FLAT = SPR_HALFTILE_SELECTION_BASE,
+ SPR_HALFTILE_SELECTION_DOWN = SPR_HALFTILE_SELECTION_BASE + 4,
+ SPR_HALFTILE_SELECTION_UP = SPR_HALFTILE_SELECTION_BASE + 8,
+
/* Flags sprites (in same order as enum NetworkLanguage) */
- SPR_FLAGS_BASE = SPR_EMPTY_BOUNDING_BOX + 1,
+ SPR_FLAGS_BASE = SPR_HALFTILE_SELECTION_BASE + 12,
/* Manager face sprites */
SPR_GRADIENT = 874, // background gradient behind manager face