station_cmd.c
changeset 2008 c9d6585c96c8
parent 1981 de031d2aed47
child 2049 ad0d49c916d4
equal deleted inserted replaced
2007:b3bdf698ee26 2008:c9d6585c96c8
    17 #include "economy.h"
    17 #include "economy.h"
    18 #include "player.h"
    18 #include "player.h"
    19 #include "airport.h"
    19 #include "airport.h"
    20 #include "sprite.h"
    20 #include "sprite.h"
    21 #include "depot.h"
    21 #include "depot.h"
       
    22 #include "pbs.h"
    22 
    23 
    23 enum {
    24 enum {
    24 	/* Max stations: 64000 (64 * 1000) */
    25 	/* Max stations: 64000 (64 * 1000) */
    25 	STATION_POOL_BLOCK_SIZE_BITS = 6,       /* In bits, so (1 << 6) == 64 */
    26 	STATION_POOL_BLOCK_SIZE_BITS = 6,       /* In bits, so (1 << 6) == 64 */
    26 	STATION_POOL_MAX_BLOCKS      = 1000,
    27 	STATION_POOL_MAX_BLOCKS      = 1000,
  2118 	uint32 image_or_modificator;
  2119 	uint32 image_or_modificator;
  2119 	uint32 image;
  2120 	uint32 image;
  2120 	const DrawTileSeqStruct *dtss;
  2121 	const DrawTileSeqStruct *dtss;
  2121 	const DrawTileSprites *t = NULL;
  2122 	const DrawTileSprites *t = NULL;
  2122 	byte railtype = _map3_lo[ti->tile] & 0xF;
  2123 	byte railtype = _map3_lo[ti->tile] & 0xF;
       
  2124 	int type_offset;
  2123 	uint32 relocation = 0;
  2125 	uint32 relocation = 0;
  2124 
  2126 
  2125 	{
  2127 	{
  2126 		uint owner = GetTileOwner(ti->tile);
  2128 		uint owner = GetTileOwner(ti->tile);
  2127 		image_or_modificator = 0x315 << 16; /* NOTE: possible bug in ttd here? */
  2129 		image_or_modificator = 0x315 << 16; /* NOTE: possible bug in ttd here? */
  2152 
  2154 
  2153 	image = t->ground_sprite;
  2155 	image = t->ground_sprite;
  2154 	if (image & 0x8000)
  2156 	if (image & 0x8000)
  2155 		image |= image_or_modificator;
  2157 		image |= image_or_modificator;
  2156 
  2158 
       
  2159 	// For custom sprites, there's no railtype-based pitching.
       
  2160 	type_offset = railtype * ((image & 0x3FFF) < _custom_sprites_base ? TRACKTYPE_SPRITE_PITCH : 1);
       
  2161 
  2157 	// station_land array has been increased from 82 elements to 114
  2162 	// station_land array has been increased from 82 elements to 114
  2158 	// but this is something else. If AI builds station with 114 it looks all weird
  2163 	// but this is something else. If AI builds station with 114 it looks all weird
  2159 	image += railtype * ((image & 0x3FFF) < _custom_sprites_base ? TRACKTYPE_SPRITE_PITCH : 1);
  2164 	image += type_offset;
  2160 	DrawGroundSprite(image);
  2165 	DrawGroundSprite(image);
  2161 
  2166 
       
  2167 	if (_debug_pbs_level >= 1) {
       
  2168 		byte pbs = PBSTileReserved(ti->tile);
       
  2169 		if (pbs & TRACK_BIT_DIAG1) DrawGroundSprite((0x3ED + type_offset) | PALETTE_CRASH);
       
  2170 		if (pbs & TRACK_BIT_DIAG2) DrawGroundSprite((0x3EE + type_offset) | PALETTE_CRASH);
       
  2171 		if (pbs & TRACK_BIT_UPPER) DrawGroundSprite((0x3EF + type_offset) | PALETTE_CRASH);
       
  2172 		if (pbs & TRACK_BIT_LOWER) DrawGroundSprite((0x3F0 + type_offset) | PALETTE_CRASH);
       
  2173 		if (pbs & TRACK_BIT_LEFT)  DrawGroundSprite((0x3F2 + type_offset) | PALETTE_CRASH);
       
  2174 		if (pbs & TRACK_BIT_RIGHT) DrawGroundSprite((0x3F1 + type_offset) | PALETTE_CRASH);
       
  2175 	}
       
  2176 
  2162 	foreach_draw_tile_seq(dtss, t->seq) {
  2177 	foreach_draw_tile_seq(dtss, t->seq) {
  2163 		image =	dtss->image + relocation;
  2178 		image = dtss->image + relocation;
  2164 		// For custom sprites, there's no railtype-based pitching.
  2179 		image += type_offset;
  2165 		image += railtype * ((image & 0x3FFF) < _custom_sprites_base ? TRACKTYPE_SPRITE_PITCH : 0);
       
  2166 		if (_display_opt & DO_TRANS_BUILDINGS) {
  2180 		if (_display_opt & DO_TRANS_BUILDINGS) {
  2167 			image = (image & 0x3FFF) | 0x03224000;
  2181 			image = (image & 0x3FFF) | 0x03224000;
  2168 		} else {
  2182 		} else {
  2169 			if (image&0x8000) image |= image_or_modificator;
  2183 			if (image&0x8000) image |= image_or_modificator;
  2170 		}
  2184 		}