(svn r4568) CodeChange : Bring definitions and uses of DrawTypesStructures toguether.

This commit is contained in:
belugas 2006-04-24 21:10:56 +00:00
parent 7aed9a62f2
commit ebf6797678
8 changed files with 70 additions and 87 deletions

View File

@ -20,6 +20,8 @@
#include "economy.h"
#include "sound.h"
#include "variables.h"
#include "table/industry_land.h"
#include "table/build_industry.h"
enum {
/* Max industries: 64000 (8 * 8000) */
@ -47,52 +49,6 @@ void ShowIndustryViewWindow(int industry);
void BuildOilRig(TileIndex tile);
void DeleteOilRig(TileIndex tile);
typedef struct DrawIndustryTileStruct {
uint32 sprite_1;
uint32 sprite_2;
byte subtile_x:4;
byte subtile_y:4;
byte width:4;
byte height:4;
byte dz;
byte proc;
} DrawIndustryTileStruct;
typedef struct DrawIndustrySpec1Struct {
byte x;
byte image_1;
byte image_2;
byte image_3;
} DrawIndustrySpec1Struct;
typedef struct DrawIndustrySpec4Struct {
byte image_1;
byte image_2;
byte image_3;
} DrawIndustrySpec4Struct;
typedef struct IndustryTileTable {
TileIndexDiffC ti;
IndustryGfx gfx;
} IndustryTileTable;
typedef struct IndustrySpec {
const IndustryTileTable *const *table;
byte num_table;
byte a,b,c;
CargoID produced_cargo[2];
byte production_rate[2];
CargoID accepts_cargo[3];
byte check_proc;
} IndustrySpec;
#include "table/industry_land.h"
#include "table/build_industry.h"
static const IndustryType _industry_close_mode[IT_END] = {
/* COAL_MINE */ INDUSTRYLIFE_PRODUCTION,
/* POWER_STATION */ INDUSTRYLIFE_NOT_CLOSABLE,
@ -367,7 +323,7 @@ static IndustryDrawTileProc * const _industry_draw_tile_procs[5] = {
static void DrawTile_Industry(TileInfo *ti)
{
const Industry* ind;
const DrawIndustryTileStruct *dits;
const DrawBuildingsTileStruct *dits;
byte z;
uint32 image, ormod;
@ -378,7 +334,7 @@ static void DrawTile_Industry(TileInfo *ti)
/* Retrieve pointer to the draw industry tile struct */
dits = &_industry_draw_tile_data[GetIndustryGfx(ti->tile) << 2 | GetIndustryConstructionStage(ti->tile)];
image = dits->sprite_1;
image = dits->ground;
if (image & PALETTE_MODIFIER_COLOR && (image & PALETTE_SPRITE_MASK) == 0)
image |= ormod;
@ -394,7 +350,7 @@ static void DrawTile_Industry(TileInfo *ti)
}
/* Add industry on top of the ground? */
image = dits->sprite_2;
image = dits->building;
if (image != 0) {
if (image & PALETTE_MODIFIER_COLOR && (image & PALETTE_SPRITE_MASK) == 0)
image |= ormod;
@ -413,7 +369,7 @@ static void DrawTile_Industry(TileInfo *ti)
}
{
int proc = dits->proc - 1;
int proc = dits->draw_proc - 1;
if (proc >= 0) _industry_draw_tile_procs[proc](ti);
}
}

View File

@ -22,6 +22,21 @@ typedef struct DrawTileSprites {
const DrawTileSeqStruct* seq;
} DrawTileSprites;
/**
* This structure is the same for both Industries and Houses.
* Buildings here reference a general type of construction
*/
typedef struct DrawBuildingsTileStruct {
SpriteID ground;
SpriteID building;
byte subtile_x:4;
byte subtile_y:4;
byte width:4;
byte height:4;
byte dz;
byte draw_proc; /* this allows to specify a special drawing procedure.*/
} DrawBuildingsTileStruct;
// Iterate through all DrawTileSeqStructs in DrawTileSprites.
#define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++)

View File

@ -1,5 +1,21 @@
/* $Id$ */
typedef struct IndustryTileTable {
TileIndexDiffC ti;
IndustryGfx gfx;
} IndustryTileTable;
typedef struct IndustrySpec {
const IndustryTileTable *const *table;
byte num_table;
byte a,b,c;
CargoID produced_cargo[2];
byte production_rate[2];
CargoID accepts_cargo[3];
byte check_proc;
} IndustrySpec;
#define MK(x,y, m) {{x, y}, m}
#define MKEND {{-0x80, 0}, 0}

View File

@ -1,8 +1,21 @@
/* $Id$ */
typedef struct DrawIndustrySpec1Struct {
byte x;
byte image_1;
byte image_2;
byte image_3;
} DrawIndustrySpec1Struct;
typedef struct DrawIndustrySpec4Struct {
byte image_1;
byte image_2;
byte image_3;
} DrawIndustrySpec4Struct;
#define M(s1, s2, sx, sy, w, h, dz, p) { s1, s2, sx, sy, w - 1, h - 1, dz, p }
static const DrawIndustryTileStruct _industry_draw_tile_data[700] = {
static const DrawBuildingsTileStruct _industry_draw_tile_data[700] = {
M( 0xf54, 0x7db, 7, 0, 9, 9, 10, 0),
M( 0xf54, 0x7dc, 7, 0, 9, 9, 30, 0),
M( 0xf54, 0x7dd, 7, 0, 9, 9, 30, 0),

View File

@ -28,7 +28,7 @@ enum {
*/
#define M(s1, s2, sx, sy, w, h, dz, p) {s1, s2, sx, sy, w - 1, h - 1, dz, p}
static const DrawTownTileStruct _town_draw_tile_data[] = {
static const DrawBuildingsTileStruct _town_draw_tile_data[] = {
M( 0xf54, 0x58d, 0, 0, 14, 14, 8, 0),
M( 0xf54, 0x58e, 0, 0, 14, 14, 60, 0),
M( 0xf54, 0x58f, 0, 0, 14, 14, 60, 0),

View File

@ -1,5 +1,15 @@
/* $Id$ */
typedef struct DrawTileUnmovableStruct {
uint16 image;
byte subcoord_x;
byte subcoord_y;
byte width;
byte height;
byte z_size;
byte unused;
} DrawTileUnmovableStruct;
#define TILE_SEQ_END() { 0x80, 0, 0, 0, 0, 0, 0 }
static const DrawTileUnmovableStruct _draw_tile_unmovable_data[] = {

View File

@ -26,6 +26,7 @@
#include "water_map.h"
#include "variables.h"
#include "bridge.h"
#include "table/town_land.h"
enum {
/* Max towns: 64000 (8 * 8000) */
@ -54,21 +55,6 @@ static bool BuildTownHouse(Town *t, TileIndex tile);
static void ClearTownHouse(Town *t, TileIndex tile);
static void DoBuildTownHouse(Town *t, TileIndex tile);
typedef struct DrawTownTileStruct {
SpriteID sprite_1;
SpriteID sprite_2;
byte subtile_x:4;
byte subtile_y:4;
byte width:4;
byte height:4;
byte dz;
byte proc;
} DrawTownTileStruct;
#include "table/town_land.h"
static void TownDrawHouseLift(const TileInfo *ti)
{
AddChildSpriteScreen(SPR_LIFT, 14, 60 - GetLiftPosition(ti->tile));
@ -82,22 +68,20 @@ static TownDrawTileProc * const _town_draw_tile_procs[1] = {
static void DrawTile_Town(TileInfo *ti)
{
const DrawTownTileStruct *dcts;
const DrawBuildingsTileStruct *dcts;
byte z;
uint32 image;
/* Retrieve pointer to the draw town tile struct */
{
/* this "randomizes" on the (up to) 4 variants of a building */
byte gfx = GetHouseType(ti->tile);
byte stage = GetHouseBuildingStage(ti->tile);
uint variant;
variant = ti->x >> 4;
variant ^= ti->x >> 6;
variant ^= ti->y >> 4;
variant -= ti->y >> 6;
variant &= 3;
dcts = &_town_draw_tile_data[gfx << 4 | variant << 2 | stage];
dcts = &_town_draw_tile_data[GetHouseType(ti->tile) << 4 | variant << 2 | GetHouseBuildingStage(ti->tile)];
}
z = ti->z;
@ -105,15 +89,15 @@ static void DrawTile_Town(TileInfo *ti)
/* Add bricks below the house? */
if (ti->tileh != SLOPE_FLAT) {
AddSortableSpriteToDraw(SPR_FOUNDATION_BASE + ti->tileh, ti->x, ti->y, 16, 16, 7, z);
AddChildSpriteScreen(dcts->sprite_1, 31, 1);
AddChildSpriteScreen(dcts->ground, 31, 1);
z += TILE_HEIGHT;
} else {
/* Else draw regular ground */
DrawGroundSprite(dcts->sprite_1);
DrawGroundSprite(dcts->ground);
}
/* Add a house on top of the ground? */
image = dcts->sprite_2;
image = dcts->building;
if (image != 0) {
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
@ -129,7 +113,7 @@ static void DrawTile_Town(TileInfo *ti)
}
{
int proc = dcts->proc - 1;
int proc = dcts->draw_proc - 1;
if (proc >= 0) _town_draw_tile_procs[proc](ti);
}

View File

@ -17,6 +17,7 @@
#include "sprite.h"
#include "unmovable_map.h"
#include "variables.h"
#include "table/unmovable_land.h"
/** Destroy a HQ.
* During normal gameplay you can only implicitely destroy a HQ when you are
@ -119,18 +120,6 @@ int32 CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
return cost;
}
typedef struct DrawTileUnmovableStruct {
uint16 image;
byte subcoord_x;
byte subcoord_y;
byte width;
byte height;
byte z_size;
byte unused;
} DrawTileUnmovableStruct;
#include "table/unmovable_land.h"
static void DrawTile_Unmovable(TileInfo *ti)
{
uint32 image, ormod;