src/elrail.cpp
changeset 6427 7dc1012757d8
parent 6269 3e10e20eecff
child 6450 54f746fcae4a
equal deleted inserted replaced
6426:dcfdb9b5991b 6427:7dc1012757d8
   267 						/* We have a neighour that will draw it, bail out */
   267 						/* We have a neighour that will draw it, bail out */
   268 						if (trackconfig[TS_NEIGHBOUR] != 0) break;
   268 						if (trackconfig[TS_NEIGHBOUR] != 0) break;
   269 						continue; /* No neighbour, go looking for a better position */
   269 						continue; /* No neighbour, go looking for a better position */
   270 					}
   270 					}
   271 
   271 
   272 					AddSortableSpriteToDraw(pylons_normal[temp], PAL_NONE, x, y, 1, 1, 10,
   272 					SpriteID img = pylons_normal[temp];
       
   273 					SpriteID pal = PAL_NONE;
       
   274 					if (_transparent_opt & TO_BUILDINGS) {
       
   275 						SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
       
   276 						pal = PALETTE_TO_TRANSPARENT;
       
   277 					}
       
   278 
       
   279 					AddSortableSpriteToDraw(img, pal, x, y, 1, 1, 10,
   273 							GetSlopeZ(ti->x + x_pcp_offsets[i], ti->y + y_pcp_offsets[i]));
   280 							GetSlopeZ(ti->x + x_pcp_offsets[i], ti->y + y_pcp_offsets[i]));
   274 					break; /* We already have drawn a pylon, bail out */
   281 					break; /* We already have drawn a pylon, bail out */
   275 				}
   282 				}
   276 			}
   283 			}
   277 		}
   284 		}
   278 	}
   285 	}
   279 
   286 
   280 	/* Don't draw a wire under a low bridge */
   287 	/* Don't draw a wire under a low bridge */
   281 	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !(_display_opt & DO_TRANS_BUILDINGS)) {
   288 	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !(_transparent_opt & TO_BUILDINGS)) {
   282 		uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
   289 		uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
   283 
   290 
   284 		if (height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) return;
   291 		if (height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) return;
   285 	}
   292 	}
   286 
   293 
   305 
   312 
   306 			assert(PCPconfig != 0); /* We have a pylon on neither end of the wire, that doesn't work (since we have no sprites for that) */
   313 			assert(PCPconfig != 0); /* We have a pylon on neither end of the wire, that doesn't work (since we have no sprites for that) */
   307 			assert(!IsSteepSlope(tileh[TS_HOME]));
   314 			assert(!IsSteepSlope(tileh[TS_HOME]));
   308 			sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]];
   315 			sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]];
   309 
   316 
   310 			AddSortableSpriteToDraw( sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
   317 			SpriteID img = sss->image;
       
   318 			SpriteID pal = PAL_NONE;
       
   319 			if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
       
   320 				SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
       
   321 				pal = PALETTE_TO_TRANSPARENT;
       
   322 			}
       
   323 
       
   324 			AddSortableSpriteToDraw(img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
   311 				sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + min(sss->x_offset, TILE_SIZE - 1), ti->y + min(sss->y_offset, TILE_SIZE - 1)) + sss->z_offset);
   325 				sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + min(sss->x_offset, TILE_SIZE - 1), ti->y + min(sss->y_offset, TILE_SIZE - 1)) + sss->z_offset);
   312 		}
   326 		}
   313 	}
   327 	}
   314 }
   328 }
   315 
   329 
   337 		sss = &CatenarySpriteData[WIRE_X_FLAT_SW + (num % 2) + offset];
   351 		sss = &CatenarySpriteData[WIRE_X_FLAT_SW + (num % 2) + offset];
   338 	}
   352 	}
   339 
   353 
   340 	height = GetBridgeHeight(end);
   354 	height = GetBridgeHeight(end);
   341 
   355 
   342 	AddSortableSpriteToDraw( sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
   356 	SpriteID img = sss->image;
       
   357 	SpriteID pal = PAL_NONE;
       
   358 	if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
       
   359 		SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
       
   360 		pal = PALETTE_TO_TRANSPARENT;
       
   361 	}
       
   362 
       
   363 	AddSortableSpriteToDraw(img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
   343 		sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset
   364 		sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset
   344 	);
   365 	);
   345 
   366 
   346 	/* Finished with wires, draw pylons */
   367 	/* Finished with wires, draw pylons */
   347 	/* every other tile needs a pylon on the northern end */
   368 	/* every other tile needs a pylon on the northern end */
   348 	if (num % 2) {
   369 	if (num % 2) {
   349 		if (axis == AXIS_X) {
   370 		if (axis == AXIS_X) {
   350 			AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], PAL_NONE, ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
   371 			img = pylons_bridge[0 + HASBIT(tlg, 0)];
       
   372 			if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
       
   373 			AddSortableSpriteToDraw(img, pal, ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
   351 		} else {
   374 		} else {
   352 			AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], PAL_NONE, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height);
   375 			img = pylons_bridge[2 + HASBIT(tlg, 1)];
       
   376 			if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
       
   377 			AddSortableSpriteToDraw(img, pal, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height);
   353 		}
   378 		}
   354 	}
   379 	}
   355 
   380 
   356 	/* need a pylon on the southern end of the bridge */
   381 	/* need a pylon on the southern end of the bridge */
   357 	if (DistanceMax(ti->tile, start) == length) {
   382 	if (DistanceMax(ti->tile, start) == length) {
   358 		if (axis == AXIS_X) {
   383 		if (axis == AXIS_X) {
   359 			AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], PAL_NONE, ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
   384 			img = pylons_bridge[0 + HASBIT(tlg, 0)];
       
   385 			if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
       
   386 			AddSortableSpriteToDraw(img, pal, ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
   360 		} else {
   387 		} else {
   361 			AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], PAL_NONE, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height);
   388 			img = pylons_bridge[2 + HASBIT(tlg, 1)];
       
   389 			if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
       
   390 			AddSortableSpriteToDraw(img, pal, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height);
   362 		}
   391 		}
   363 	}
   392 	}
   364 }
   393 }
   365 
   394 
   366 void DrawCatenary(const TileInfo *ti)
   395 void DrawCatenary(const TileInfo *ti)
   377 	switch (GetTileType(ti->tile)) {
   406 	switch (GetTileType(ti->tile)) {
   378 		case MP_RAILWAY:
   407 		case MP_RAILWAY:
   379 			if (IsRailDepot(ti->tile)) {
   408 			if (IsRailDepot(ti->tile)) {
   380 				const SortableSpriteStruct *sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)];
   409 				const SortableSpriteStruct *sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)];
   381 
   410 
       
   411 				SpriteID img = sss->image;
       
   412 				SpriteID pal = PAL_NONE;
       
   413 				if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
       
   414 					SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
       
   415 					pal = PALETTE_TO_TRANSPARENT;
       
   416 				}
       
   417 
   382 				AddSortableSpriteToDraw(
   418 				AddSortableSpriteToDraw(
   383 					sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
   419 					img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
   384 					sss->x_size, sss->y_size, sss->z_size,
   420 					sss->x_size, sss->y_size, sss->z_size,
   385 					GetTileMaxZ(ti->tile) + sss->z_offset
   421 					GetTileMaxZ(ti->tile) + sss->z_offset
   386 				);
   422 				);
   387 				return;
   423 				return;
   388 			}
   424 			}