(svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)

pull/155/head
darkvater 20 years ago
parent e9ef930155
commit 7930faace9

@ -89,4 +89,22 @@ VARDEF bool _global_station_sort_dirty;
void GetProductionAroundTiles(uint *produced, uint tile, int w, int h);
void GetAcceptanceAroundTiles(uint *accepts, uint tile, int w, int h);
uint GetStationPlatforms(Station *st, uint tile);
typedef struct DrawTileSeqStruct {
int8 delta_x;
int8 delta_y;
int8 delta_z;
byte width,height;
byte unk; // 'depth', just z-size; TODO: rename
uint32 image;
} DrawTileSeqStruct;
typedef struct DrawTileSprites {
SpriteID ground_sprite;
DrawTileSeqStruct const *seq;
} DrawTileSprites;
#define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++)
#endif /* STATION_H */

@ -1717,22 +1717,13 @@ static int32 RemoveDock(Station *st, uint32 flags)
#include "table/station_land.h"
typedef struct DrawTileSeqStruct {
int8 delta_x;
int8 delta_y;
int8 delta_z;
byte width,height;
byte unk;
SpriteID image;
} DrawTileSeqStruct;
static void DrawTile_Station(TileInfo *ti)
{
uint32 image_or_modificator;
uint32 base_img, image;
const DrawTileSeqStruct *dtss;
const byte *t;
const DrawTileSprites *t;
// station_land array has been increased from 82 elements to 114
// but this is something else. If AI builds station with 114 it looks all weird
@ -1749,32 +1740,24 @@ static void DrawTile_Station(TileInfo *ti)
if (ti->tileh != 0 && (ti->map5 < 0x4C || ti->map5 > 0x51))
DrawFoundation(ti, ti->tileh);
t = _station_display_datas[ti->map5];
t = &_station_display_datas[ti->map5];
image = *(const uint32*)t;
t += sizeof(uint32);
image = t->ground_sprite;
if (image & 0x8000)
image |= image_or_modificator;
DrawGroundSprite(image + base_img);
for(dtss = (const DrawTileSeqStruct *)t; (byte)dtss->delta_x != 0x80; dtss++) {
if ((byte)dtss->delta_z != 0x80) {
image = dtss->image + base_img;
if (_display_opt & DO_TRANS_BUILDINGS) {
if (image&0x8000) image |= image_or_modificator;
} else {
image = (image & 0x3FFF) | 0x03224000;
}
foreach_draw_tile_seq(dtss, t->seq) {
image = dtss->image + base_img;
if (_display_opt & DO_TRANS_BUILDINGS) {
if (image&0x8000) image |= image_or_modificator;
} else {
image = (image & 0x3FFF) | 0x03224000;
}
if ((byte)dtss->delta_z != 0x80) {
AddSortableSpriteToDraw(image, ti->x + dtss->delta_x, ti->y + dtss->delta_y, dtss->width, dtss->height, dtss->unk, ti->z + dtss->delta_z);
} else {
image = *(const uint32*)&dtss->height + base_img; /* endian ok */
if (_display_opt & DO_TRANS_BUILDINGS) {
if (image&0x8000) image |= image_or_modificator;
} else {
image = (image & 0x3FFF) | 0x03224000;
}
AddChildSpriteScreen(image, dtss->delta_x, dtss->delta_y);
}
}
@ -1784,22 +1767,21 @@ void StationPickerDrawSprite(int x, int y, int railtype, int image)
{
uint32 ormod, img;
const DrawTileSeqStruct *dtss;
const byte *t;
const DrawTileSprites *t;
/* baseimage */
railtype *= TRACKTYPE_SPRITE_PITCH;
ormod = PLAYER_SPRITE_COLOR(_local_player);
t = _station_display_datas[image];
t = &_station_display_datas[image];
img = *(const uint32*)t;
t += sizeof(uint32);
img = t->ground_sprite;
if (img & 0x8000)
img |= ormod;
DrawSprite(img + railtype, x, y);
for(dtss = (const DrawTileSeqStruct *)t; (byte)dtss->delta_x != 0x80; dtss++) {
foreach_draw_tile_seq(dtss, t->seq) {
Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
DrawSprite((dtss->image | ormod) + railtype, x + pt.x, y + pt.y);
}

File diff suppressed because it is too large Load Diff

@ -1,141 +1,119 @@
#define TILE_SEQ_BEGIN(x) ADD_WORD(x),
#define TILE_SEQ_LINE(a,b,c,d,e,f,g) a,b,c,d,e,f,ADD_WORD(g),
#define TILE_SEQ_END() 0x80
#define TILE_SEQ_END() { 0x80 }
static const DrawTileUnmovableStruct _draw_tile_unmovable_data[] = {
{0xA29, 7,7, 2,2, 70},
{0xA2A, 4,4, 7,7, 61},
};
static const byte _unmovable_display_datas_0[] = {
TILE_SEQ_BEGIN(0x8A2B)
static const DrawTileSeqStruct _unmovable_display_datas_0[] = {
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_1[] = {
TILE_SEQ_BEGIN(0x8A2C)
static const DrawTileSeqStruct _unmovable_display_datas_1[] = {
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_2[] = {
TILE_SEQ_BEGIN(0x8A2D)
static const DrawTileSeqStruct _unmovable_display_datas_2[] = {
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_3[] = {
TILE_SEQ_BEGIN(0x8A2E)
static const DrawTileSeqStruct _unmovable_display_datas_3[] = {
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_4[] = {
TILE_SEQ_BEGIN(0x8A2F)
static const DrawTileSeqStruct _unmovable_display_datas_4[] = {
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_5[] = {
TILE_SEQ_BEGIN(0x8A30)
static const DrawTileSeqStruct _unmovable_display_datas_5[] = {
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_6[] = {
TILE_SEQ_BEGIN(0x8A31)
static const DrawTileSeqStruct _unmovable_display_datas_6[] = {
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_7[] = {
TILE_SEQ_BEGIN(0x8A32)
static const DrawTileSeqStruct _unmovable_display_datas_7[] = {
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_8[] = {
TILE_SEQ_BEGIN(0x8A33)
TILE_SEQ_LINE( 0, 0, 0, 16, 16, 20, 0x8A34)
static const DrawTileSeqStruct _unmovable_display_datas_8[] = {
{ 0, 0, 0, 16, 16, 20, 0x8A34 },
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_9[] = {
TILE_SEQ_BEGIN(0x8A35)
TILE_SEQ_LINE( 0, 0, 0, 16, 16, 20, 0x8A36)
static const DrawTileSeqStruct _unmovable_display_datas_9[] = {
{ 0, 0, 0, 16, 16, 20, 0x8A36 },
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_10[] = {
TILE_SEQ_BEGIN(0x8A37)
TILE_SEQ_LINE( 0, 0, 0, 16, 16, 20, 0x8A38)
static const DrawTileSeqStruct _unmovable_display_datas_10[] = {
{ 0, 0, 0, 16, 16, 20, 0x8A38 },
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_11[] = {
TILE_SEQ_BEGIN(0x8A39)
static const DrawTileSeqStruct _unmovable_display_datas_11[] = {
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_12[] = {
TILE_SEQ_BEGIN(0x8A3A)
TILE_SEQ_LINE( 0, 0, 0, 16, 16, 50, 0x8A3B)
static const DrawTileSeqStruct _unmovable_display_datas_12[] = {
{ 0, 0, 0, 16, 16, 50, 0x8A3B },
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_13[] = {
TILE_SEQ_BEGIN(0x8A3C)
TILE_SEQ_LINE( 0, 0, 0, 16, 16, 50, 0x8A3D)
static const DrawTileSeqStruct _unmovable_display_datas_13[] = {
{ 0, 0, 0, 16, 16, 50, 0x8A3D },
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_14[] = {
TILE_SEQ_BEGIN(0x8A3E)
TILE_SEQ_LINE( 0, 0, 0, 16, 16, 50, 0x8A3F)
static const DrawTileSeqStruct _unmovable_display_datas_14[] = {
{ 0, 0, 0, 16, 16, 50, 0x8A3F },
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_15[] = {
TILE_SEQ_BEGIN(0x8A40)
static const DrawTileSeqStruct _unmovable_display_datas_15[] = {
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_16[] = {
TILE_SEQ_BEGIN(0x8A41)
TILE_SEQ_LINE( 0, 0, 0, 16, 16, 60, 0x8A42)
static const DrawTileSeqStruct _unmovable_display_datas_16[] = {
{ 0, 0, 0, 16, 16, 60, 0x8A42 },
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_17[] = {
TILE_SEQ_BEGIN(0x8A43)
TILE_SEQ_LINE( 0, 0, 0, 16, 16, 60, 0x8A44)
static const DrawTileSeqStruct _unmovable_display_datas_17[] = {
{ 0, 0, 0, 16, 16, 60, 0x8A44 },
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_18[] = {
TILE_SEQ_BEGIN(0x8A45)
TILE_SEQ_LINE( 0, 0, 0, 16, 16, 60, 0x8A46)
static const DrawTileSeqStruct _unmovable_display_datas_18[] = {
{ 0, 0, 0, 16, 16, 60, 0x8A46 },
TILE_SEQ_END()
};
static const byte _unmovable_display_datas_19[] = {
TILE_SEQ_BEGIN(0x8A47)
static const DrawTileSeqStruct _unmovable_display_datas_19[] = {
TILE_SEQ_END()
};
static const byte * const _unmovable_display_datas[] = {
_unmovable_display_datas_0,
_unmovable_display_datas_1,
_unmovable_display_datas_2,
_unmovable_display_datas_3,
_unmovable_display_datas_4,
_unmovable_display_datas_5,
_unmovable_display_datas_6,
_unmovable_display_datas_7,
_unmovable_display_datas_8,
_unmovable_display_datas_9,
_unmovable_display_datas_10,
_unmovable_display_datas_11,
_unmovable_display_datas_12,
_unmovable_display_datas_13,
_unmovable_display_datas_14,
_unmovable_display_datas_15,
_unmovable_display_datas_16,
_unmovable_display_datas_17,
_unmovable_display_datas_18,
_unmovable_display_datas_19,
static const DrawTileSprites _unmovable_display_datas[] = {
{ 0x8A2B, _unmovable_display_datas_0 },
{ 0x8A2C, _unmovable_display_datas_1 },
{ 0x8A2D, _unmovable_display_datas_2 },
{ 0x8A2E, _unmovable_display_datas_3 },
{ 0x8A2F, _unmovable_display_datas_4 },
{ 0x8A30, _unmovable_display_datas_5 },
{ 0x8A31, _unmovable_display_datas_6 },
{ 0x8A32, _unmovable_display_datas_7 },
{ 0x8A33, _unmovable_display_datas_8 },
{ 0x8A35, _unmovable_display_datas_9 },
{ 0x8A37, _unmovable_display_datas_10 },
{ 0x8A39, _unmovable_display_datas_11 },
{ 0x8A3A, _unmovable_display_datas_12 },
{ 0x8A3C, _unmovable_display_datas_13 },
{ 0x8A3E, _unmovable_display_datas_14 },
{ 0x8A40, _unmovable_display_datas_15 },
{ 0x8A41, _unmovable_display_datas_16 },
{ 0x8A43, _unmovable_display_datas_17 },
{ 0x8A45, _unmovable_display_datas_18 },
{ 0x8A47, _unmovable_display_datas_19 },
};

@ -4,6 +4,7 @@
#include "viewport.h"
#include "player.h"
#include "gui.h"
#include "station.h"
#include "economy.h"
#include "town.h"
@ -17,15 +18,6 @@ typedef struct DrawTileUnmovableStruct {
byte unused;
} DrawTileUnmovableStruct;
typedef struct DrawTileSeqStruct {
int8 delta_x;
int8 delta_y;
int8 delta_z;
byte width,height;
byte unk;
SpriteID image;
} DrawTileSeqStruct;
#include "table/unmovable_land.h"
static void DrawTile_Unmovable(TileInfo *ti)
@ -77,18 +69,16 @@ static void DrawTile_Unmovable(TileInfo *ti)
}
} else {
const DrawTileSeqStruct *dtss;
const byte *t;
const DrawTileSprites *t;
if (ti->tileh) DrawFoundation(ti, ti->tileh);
ormod = PLAYER_SPRITE_COLOR(_map_owner[ti->tile]);
t = _unmovable_display_datas[ti->map5 & 0x7F];
DrawGroundSprite(*(const uint16*)t | ormod);
t += sizeof(uint16);
t = &_unmovable_display_datas[ti->map5 & 0x7F];
DrawGroundSprite(t->ground_sprite | ormod);
for(dtss = (const DrawTileSeqStruct *)t; (byte)dtss->delta_x != 0x80; dtss++) {
foreach_draw_tile_seq(dtss, t->seq) {
image = dtss->image;
if (_display_opt & DO_TRANS_BUILDINGS) {
image |= ormod;

Loading…
Cancel
Save