tunnelbridge_cmd.c
changeset 2478 16b05f1de6bb
parent 2436 177cb6a8339f
child 2493 d834d0c1502a
equal deleted inserted replaced
2477:d454d5152386 2478:16b05f1de6bb
    29 extern const byte _track_sloped_sprites[14];
    29 extern const byte _track_sloped_sprites[14];
    30 extern const SpriteID _water_shore_sprites[15];
    30 extern const SpriteID _water_shore_sprites[15];
    31 
    31 
    32 extern void DrawCanalWater(TileIndex tile);
    32 extern void DrawCanalWater(TileIndex tile);
    33 
    33 
    34 const Bridge _bridge[] = {
    34 const Bridge orig_bridge[] = {
    35 /*
    35 /*
    36 	   year of availablity
    36 	   year of availablity
    37 	   |  minimum length
    37 	   |  minimum length
    38 	   |  |   maximum length
    38 	   |  |   maximum length
    39 	   |  |   |    price
    39 	   |  |   |    price
    40 	   |  |   |    |    maximum speed
    40 	   |  |   |    |    maximum speed
    41 	   |  |   |    |    |  sprite to use in GUI                string with description
    41 	   |  |   |    |    |  sprite to use in GUI                string with description
    42 	   |  |   |    |    |  |                                   |                            */
    42 	   |  |   |    |    |  |                                   |                            */
    43 	{  0, 0, 16,  80,  32, 0xA24                             , STR_5012_WOODEN              },
    43 	{  0, 0, 16,  80,  32, 0xA24                             , STR_5012_WOODEN             , NULL, 0 },
    44 	{  0, 0,  2, 112,  48, 0xA26 | PALETTE_TO_STRUCT_RED     , STR_5013_CONCRETE            },
    44 	{  0, 0,  2, 112,  48, 0xA26 | PALETTE_TO_STRUCT_RED     , STR_5013_CONCRETE           , NULL, 0 },
    45 	{ 10, 0,  5, 144,  64, 0xA25                             , STR_500F_GIRDER_STEEL        },
    45 	{ 10, 0,  5, 144,  64, 0xA25                             , STR_500F_GIRDER_STEEL       , NULL, 0 },
    46 	{  0, 2, 10, 168,  80, 0xA22 | PALETTE_TO_STRUCT_CONCRETE, STR_5011_SUSPENSION_CONCRETE },
    46 	{  0, 2, 10, 168,  80, 0xA22 | PALETTE_TO_STRUCT_CONCRETE, STR_5011_SUSPENSION_CONCRETE, NULL, 0 },
    47 	{ 10, 3, 16, 185,  96, 0xA22                             , STR_500E_SUSPENSION_STEEL    },
    47 	{ 10, 3, 16, 185,  96, 0xA22                             , STR_500E_SUSPENSION_STEEL   , NULL, 0 },
    48 	{ 10, 3, 16, 192, 112, 0xA22 | PALETTE_TO_STRUCT_YELLOW  , STR_500E_SUSPENSION_STEEL	},
    48 	{ 10, 3, 16, 192, 112, 0xA22 | PALETTE_TO_STRUCT_YELLOW  , STR_500E_SUSPENSION_STEEL   , NULL, 0 },
    49 	{ 10, 3,  7, 224, 160, 0xA23                             , STR_5010_CANTILEVER_STEEL    },
    49 	{ 10, 3,  7, 224, 160, 0xA23                             , STR_5010_CANTILEVER_STEEL   , NULL, 0 },
    50 	{ 10, 3,  8, 232, 208, 0xA23 | PALETTE_TO_STRUCT_BROWN   , STR_5010_CANTILEVER_STEEL    },
    50 	{ 10, 3,  8, 232, 208, 0xA23 | PALETTE_TO_STRUCT_BROWN   , STR_5010_CANTILEVER_STEEL   , NULL, 0 },
    51 	{ 10, 3,  9, 248, 240, 0xA23 | PALETTE_TO_STRUCT_RED     , STR_5010_CANTILEVER_STEEL    },
    51 	{ 10, 3,  9, 248, 240, 0xA23 | PALETTE_TO_STRUCT_RED     , STR_5010_CANTILEVER_STEEL   , NULL, 0 },
    52 	{ 10, 0,  2, 240, 256, 0xA27                             , STR_500F_GIRDER_STEEL        },
    52 	{ 10, 0,  2, 240, 256, 0xA27                             , STR_500F_GIRDER_STEEL       , NULL, 0 },
    53 	{ 75, 2, 16, 255, 320, 0xA28                             , STR_5014_TUBULAR_STEEL       },
    53 	{ 75, 2, 16, 255, 320, 0xA28                             , STR_5014_TUBULAR_STEEL      , NULL, 0 },
    54 	{ 85, 2, 32, 380, 512, 0xA28 | PALETTE_TO_STRUCT_YELLOW  , STR_5014_TUBULAR_STEEL       },
    54 	{ 85, 2, 32, 380, 512, 0xA28 | PALETTE_TO_STRUCT_YELLOW  , STR_5014_TUBULAR_STEEL      , NULL, 0 },
    55 	{ 90, 2, 32, 510, 608, 0xA28 | PALETTE_TO_STRUCT_GREY    , STR_BRIDGE_TUBULAR_SILICON   }
    55 	{ 90, 2, 32, 510, 608, 0xA28 | PALETTE_TO_STRUCT_GREY    , STR_BRIDGE_TUBULAR_SILICON  , NULL, 0 }
    56 };
    56 };
    57 
    57 
    58 // calculate the price factor for building a long bridge.
    58 // calculate the price factor for building a long bridge.
    59 // basically the cost delta is 1,1, 1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, 6,6,6,6,6,6,  7,7,7,7,7,7,7,  8,8,8,8,8,8,8,8,
    59 // basically the cost delta is 1,1, 1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, 6,6,6,6,6,6,  7,7,7,7,7,7,7,  8,8,8,8,8,8,8,8,
    60 int CalcBridgeLenCostFactor(int x)
    60 int CalcBridgeLenCostFactor(int x)
    75 	// foundation, tile is partly leveled up (tileh's 1, 2, 4, 8) --> 1 corner raised
    75 	// foundation, tile is partly leveled up (tileh's 1, 2, 4, 8) --> 1 corner raised
    76 	BRIDGE_PARTLY_LEVELED_FOUNDATION = 1 << 1 | 1 << 2 | 1 << 4 | 1 << 8,
    76 	BRIDGE_PARTLY_LEVELED_FOUNDATION = 1 << 1 | 1 << 2 | 1 << 4 | 1 << 8,
    77 	// no foundations (X,Y direction) (tileh's 0, 3, 6, 9, 12)
    77 	// no foundations (X,Y direction) (tileh's 0, 3, 6, 9, 12)
    78 	BRIDGE_NO_FOUNDATION = 1 << 0 | 1 << 3 | 1 << 6 | 1 << 9 | 1 << 12,
    78 	BRIDGE_NO_FOUNDATION = 1 << 0 | 1 << 3 | 1 << 6 | 1 << 9 | 1 << 12,
    79 };
    79 };
       
    80 
       
    81 static inline const PalSpriteID *GetBridgeSpriteTable(int index, byte table)
       
    82 {
       
    83 	const Bridge *bridge = &_bridge[index];
       
    84 	assert(table < 7);
       
    85 	if (bridge->sprite_table == NULL || bridge->sprite_table[table] == NULL) {
       
    86 		return _bridge_sprite_table[index][table];
       
    87 	} else {
       
    88 		return bridge->sprite_table[table];
       
    89 	}
       
    90 }
    80 
    91 
    81 /**
    92 /**
    82  * Determines which piece of a bridge is contained in the current tile
    93  * Determines which piece of a bridge is contained in the current tile
    83  * @param tile The tile to analyze
    94  * @param tile The tile to analyze
    84  * @return the piece
    95  * @return the piece
  1065 				// default sloped sprites..
  1076 				// default sloped sprites..
  1066 				if (ti->tileh != 0) image = _track_sloped_sprites[ti->tileh - 1] + 0x3F3;
  1077 				if (ti->tileh != 0) image = _track_sloped_sprites[ti->tileh - 1] + 0x3F3;
  1067 			}
  1078 			}
  1068 
  1079 
  1069 			// bridge ending.
  1080 			// bridge ending.
  1070 			b = _bridge_sprite_table[GB(_m[ti->tile].m2, 4, 4)][6];
  1081 			b = GetBridgeSpriteTable(GetBridgeType(ti->tile), 6);
  1071 			b += (tmp&(3<<1))*4; /* actually ((tmp>>2)&3)*8 */
  1082 			b += (tmp&(3<<1))*4; /* actually ((tmp>>2)&3)*8 */
  1072 			b += (tmp&1); // direction
  1083 			b += (tmp&1); // direction
  1073 			if (ti->tileh == 0) b += 4; // sloped "entrance" ?
  1084 			if (ti->tileh == 0) b += 4; // sloped "entrance" ?
  1074 			if (ti->map5 & 0x20) b += 2; // which side
  1085 			if (ti->map5 & 0x20) b += 2; // which side
  1075 
  1086 
  1126 					if (ice) image += 19; // ice?
  1137 					if (ice) image += 19; // ice?
  1127 				}
  1138 				}
  1128 				DrawGroundSprite(image);
  1139 				DrawGroundSprite(image);
  1129 			}
  1140 			}
  1130 			// get bridge sprites
  1141 			// get bridge sprites
  1131 			b = _bridge_sprite_table[GB(_m[ti->tile].m2, 4, 4)][GB(_m[ti->tile].m2, 0, 4)] + tmp * 4;
  1142 			b = GetBridgeSpriteTable(GetBridgeType(ti->tile), GetBridgePiece(ti->tile)) + tmp * 4;
  1132 
  1143 
  1133 			z = GetBridgeHeight(ti) + 5;
  1144 			z = GetBridgeHeight(ti) + 5;
  1134 
  1145 
  1135 			// draw rail
  1146 			// draw rail
  1136 			image = b[0];
  1147 			image = b[0];