Changeset - r3737:eb79e5f07768
[Not reviewed]
master
0 3 0
peter1138 - 19 years ago 2006-05-03 20:35:41
peter1138@openttd.org
(svn r4719) - Newstations: instead of drawing nothing, fall back to the default sprite layout if a station layout specifies so.
3 files changed with 22 insertions and 27 deletions:
0 comments (0 inline, 0 general)
newgrf.c
Show inline comments
 
@@ -807,28 +807,24 @@ static bool StationChangeInfo(uint stid,
 
				statspec->renderdata = calloc(statspec->tiles, sizeof(*statspec->renderdata));
 
				for (t = 0; t < statspec->tiles; t++) {
 
					DrawTileSprites *dts = &statspec->renderdata[t];
 
					uint seq_count = 0;
 
					PalSpriteID ground_sprite;
 

	
 
					dts->seq = NULL;
 
					ground_sprite = grf_load_dword(&buf);
 
					if (ground_sprite == 0) {
 
						static const DrawTileSeqStruct empty = {0x80, 0, 0, 0, 0, 0, 0};
 
						dts->seq = &empty;
 
						continue;
 
					}
 
					if (ground_sprite == 0) continue;
 

	
 
					if (HASBIT(ground_sprite, 31)) {
 
						// Bit 31 indicates that we should use a custom sprite.
 
						dts->ground_sprite = GB(ground_sprite, 0, 15) - 0x42D;
 
						dts->ground_sprite += _cur_grffile->first_spriteset;
 
					} else {
 
						dts->ground_sprite = ground_sprite;
 
					}
 

	
 
					dts->seq = NULL;
 
					while (buf < *bufp + len) {
 
						DrawTileSeqStruct *dtss;
 

	
 
						// no relative bounding box support
 
						dts->seq = realloc((void*)dts->seq, ++seq_count * sizeof(DrawTileSeqStruct));
 
						dtss = (DrawTileSeqStruct*) &dts->seq[seq_count - 1];
 
@@ -858,21 +854,17 @@ static bool StationChangeInfo(uint stid,
 
				for (t = 0; t < statspec->tiles; t++) {
 
					DrawTileSprites *dts = &statspec->renderdata[t];
 
					const DrawTileSprites *sdts = &srcstatspec->renderdata[t];
 
					DrawTileSeqStruct const *sdtss = sdts->seq;
 
					int seq_count = 0;
 

	
 
					dts->seq = NULL;
 
					dts->ground_sprite = sdts->ground_sprite;
 
					if (dts->ground_sprite == 0) {
 
						static const DrawTileSeqStruct empty = {0x80, 0, 0, 0, 0, 0, 0};
 
						dts->seq = &empty;
 
						continue;
 
					}
 

	
 
					dts->seq = NULL;
 
					while (1) {
 
					if (dts->ground_sprite == 0) continue;
 

	
 
					while (true) {
 
						DrawTileSeqStruct *dtss;
 

	
 
						// no relative bounding box support
 
						dts->seq = realloc((void*)dts->seq, ++seq_count * sizeof(DrawTileSeqStruct));
 
						dtss = (DrawTileSeqStruct*) &dts->seq[seq_count - 1];
 
						*dtss = *sdtss;
rail_cmd.c
Show inline comments
 
@@ -1332,35 +1332,38 @@ static void DrawTile_Track(TileInfo *ti)
 
				 * do that for custom ground sprites and never
 
				 * for station sprites. And in the drawing
 
				 * code, it is used to indicate that the sprite
 
				 * should be drawn in company colors, and it's
 
				 * up to the GRF file to decide that. */
 

	
 
				image = cust->ground_sprite;
 
				image += (image < _custom_sprites_base) ? rti->total_offset : rti->custom_ground_offset;
 
				/* If there is no sprite layout, we fall back to the default waypoint graphics. */
 
				if (cust != NULL && cust->seq != NULL) {
 
					image = cust->ground_sprite;
 
					image += (image < _custom_sprites_base) ? rti->total_offset : rti->custom_ground_offset;
 

	
 
				DrawGroundSprite(image);
 
					DrawGroundSprite(image);
 

	
 
				if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
 
					if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
 

	
 
				foreach_draw_tile_seq(seq, cust->seq) {
 
					DrawSpecialBuilding(
 
						seq->image + relocation, 0, ti,
 
						seq->delta_x, seq->delta_y, seq->delta_z,
 
						seq->width, seq->height, seq->unk
 
					);
 
					foreach_draw_tile_seq(seq, cust->seq) {
 
						DrawSpecialBuilding(
 
							seq->image + relocation, 0, ti,
 
							seq->delta_x, seq->delta_y, seq->delta_z,
 
							seq->width, seq->height, seq->unk
 
						);
 
					}
 
					return;
 
				}
 
				return;
 
			}
 
		}
 

	
 
		drss = is_depot ? _track_depot_layout_table[GetRailDepotDirection(ti->tile)] : _track_waypoint_layout_table[GetWaypointAxis(ti->tile)];
 

	
 
		image = drss++->image;
 
		/* @note This is kind of an ugly hack, as the PALETTE_MODIFIER_COLOR indicates
 
	 	 * whether the sprite is railtype dependent. Rewrite this asap */
 
		 * whether the sprite is railtype dependent. Rewrite this asap */
 
		if (image & PALETTE_MODIFIER_COLOR) image = (image & SPRITE_MASK) + rti->total_offset;
 

	
 
		// adjust ground tile for desert
 
		// (don't adjust for arctic depots, because snow in depots looks weird)
 
		// type >= 4 means waypoints
 
		if (IsSnowRailGround(ti->tile) && (_opt.landscape == LT_DESERT || !is_depot)) {
station_cmd.c
Show inline comments
 
@@ -1993,13 +1993,13 @@ static void DrawTile_Station(TileInfo *t
 

	
 
			/* Ensure the chosen tile layout is valid for this custom station */
 
			t = &statspec->renderdata[tile < statspec->tiles ? tile : GetRailStationAxis(ti->tile)];
 
		}
 
	}
 

	
 
	if (t == NULL) t = &_station_display_datas[GetStationGfx(ti->tile)];
 
	if (t == NULL || t->seq == NULL) t = &_station_display_datas[GetStationGfx(ti->tile)];
 

	
 
	image = t->ground_sprite;
 
	if (image & PALETTE_MODIFIER_COLOR) image |= image_or_modificator;
 

	
 
	// For custom sprites, there's no railtype-based pitching.
 
	offset = (image & SPRITE_MASK) < _custom_sprites_base ? rti->total_offset : rti->custom_ground_offset;
0 comments (0 inline, 0 general)