changeset 8260 | c7d75cebe3f6 |
parent 8259 | 127e5d73637d |
child 8266 | 48fa6a084b98 |
8259:127e5d73637d | 8260:c7d75cebe3f6 |
---|---|
1236 } |
1236 } |
1237 } |
1237 } |
1238 |
1238 |
1239 #include "table/track_land.h" |
1239 #include "table/track_land.h" |
1240 |
1240 |
1241 /** |
|
1242 * Get surface height in point (x,y) |
|
1243 * On tiles with halftile foundations move (x,y) to a save point wrt. track |
|
1244 */ |
|
1245 static uint GetSaveSlopeZ(uint x, uint y, Track track) |
|
1246 { |
|
1247 switch (track) { |
|
1248 case TRACK_UPPER: x &= ~0xF; y &= ~0xF; break; |
|
1249 case TRACK_LOWER: x |= 0xF; y |= 0xF; break; |
|
1250 case TRACK_LEFT: x |= 0xF; y &= ~0xF; break; |
|
1251 case TRACK_RIGHT: x &= ~0xF; y |= 0xF; break; |
|
1252 default: break; |
|
1253 } |
|
1254 return GetSlopeZ(x, y); |
|
1255 } |
|
1256 |
|
1241 static void DrawSingleSignal(TileIndex tile, Track track, byte condition, uint image, uint pos) |
1257 static void DrawSingleSignal(TileIndex tile, Track track, byte condition, uint image, uint pos) |
1242 { |
1258 { |
1243 bool side = (_opt.road_side != 0) && _patches.signal_side; |
1259 bool side = (_opt.road_side != 0) && _patches.signal_side; |
1244 static const Point SignalPositions[2][12] = { |
1260 static const Point SignalPositions[2][12] = { |
1245 { /* Signals on the left side */ |
1261 { /* Signals on the left side */ |
1279 sprite = SignalBase[side][GetSignalVariant(tile, track)][GetSignalType(tile, track)] + image + condition; |
1295 sprite = SignalBase[side][GetSignalVariant(tile, track)][GetSignalType(tile, track)] + image + condition; |
1280 } else { |
1296 } else { |
1281 sprite = _signal_base + (GetSignalType(tile, track) - 1) * 16 + GetSignalVariant(tile, track) * 64 + image + condition; |
1297 sprite = _signal_base + (GetSignalType(tile, track) - 1) * 16 + GetSignalVariant(tile, track) * 64 + image + condition; |
1282 } |
1298 } |
1283 |
1299 |
1284 AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSlopeZ(x,y)); |
1300 AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSaveSlopeZ(x, y, track)); |
1285 } |
1301 } |
1286 |
1302 |
1287 static uint32 _drawtile_track_palette; |
1303 static uint32 _drawtile_track_palette; |
1288 |
1304 |
1289 |
1305 |
1336 */ |
1352 */ |
1337 static void DrawTrackFence_NS_1(const TileInfo *ti) |
1353 static void DrawTrackFence_NS_1(const TileInfo *ti) |
1338 { |
1354 { |
1339 int z = ti->z; |
1355 int z = ti->z; |
1340 if (ti->tileh & SLOPE_W) z += TILE_HEIGHT; |
1356 if (ti->tileh & SLOPE_W) z += TILE_HEIGHT; |
1357 if (IsSteepSlope(ti->tileh)) z += TILE_HEIGHT; |
|
1341 AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_VERT, _drawtile_track_palette, |
1358 AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_VERT, _drawtile_track_palette, |
1342 ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
1359 ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
1343 } |
1360 } |
1344 |
1361 |
1345 /** |
1362 /** |
1347 */ |
1364 */ |
1348 static void DrawTrackFence_NS_2(const TileInfo *ti) |
1365 static void DrawTrackFence_NS_2(const TileInfo *ti) |
1349 { |
1366 { |
1350 int z = ti->z; |
1367 int z = ti->z; |
1351 if (ti->tileh & SLOPE_E) z += TILE_HEIGHT; |
1368 if (ti->tileh & SLOPE_E) z += TILE_HEIGHT; |
1369 if (IsSteepSlope(ti->tileh)) z += TILE_HEIGHT; |
|
1352 AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_VERT, _drawtile_track_palette, |
1370 AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_VERT, _drawtile_track_palette, |
1353 ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
1371 ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
1354 } |
1372 } |
1355 |
1373 |
1356 /** |
1374 /** |
1358 */ |
1376 */ |
1359 static void DrawTrackFence_WE_1(const TileInfo *ti) |
1377 static void DrawTrackFence_WE_1(const TileInfo *ti) |
1360 { |
1378 { |
1361 int z = ti->z; |
1379 int z = ti->z; |
1362 if (ti->tileh & SLOPE_N) z += TILE_HEIGHT; |
1380 if (ti->tileh & SLOPE_N) z += TILE_HEIGHT; |
1381 if (IsSteepSlope(ti->tileh)) z += TILE_HEIGHT; |
|
1363 AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_HORZ, _drawtile_track_palette, |
1382 AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_HORZ, _drawtile_track_palette, |
1364 ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
1383 ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
1365 } |
1384 } |
1366 |
1385 |
1367 /** |
1386 /** |
1369 */ |
1388 */ |
1370 static void DrawTrackFence_WE_2(const TileInfo *ti) |
1389 static void DrawTrackFence_WE_2(const TileInfo *ti) |
1371 { |
1390 { |
1372 int z = ti->z; |
1391 int z = ti->z; |
1373 if (ti->tileh & SLOPE_S) z += TILE_HEIGHT; |
1392 if (ti->tileh & SLOPE_S) z += TILE_HEIGHT; |
1393 if (IsSteepSlope(ti->tileh)) z += TILE_HEIGHT; |
|
1374 AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_HORZ, _drawtile_track_palette, |
1394 AddSortableSpriteToDraw(SPR_TRACK_FENCE_FLAT_HORZ, _drawtile_track_palette, |
1375 ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
1395 ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
1376 } |
1396 } |
1377 |
1397 |
1378 |
1398 |