Changeset - r26697:ec39edce267d
[Not reviewed]
master
0 7 0
Francis Herne - 18 months ago 2022-12-26 20:06:21
mail@flherne.uk
Add: Slope-aware and roadtype-specific one-way sprites. (#10282)
7 files changed with 46 insertions and 11 deletions:
0 comments (0 inline, 0 general)
media/baseset/openttd.grf
Show inline comments
 
binary diff not shown
media/baseset/openttd/oneway.nfo
Show inline comments
 
@@ -4,10 +4,24 @@
 
// See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
//
 
   -1 * 0	 0C "One way road graphics"
 
   -1 * 3	 05 09 06
 
   -1 sprites/oneway.png 8bpp  34    8  24  16 -12  -8 normal
 
   -1 sprites/oneway.png 8bpp  66    8  24  16 -12  -8 normal
 
   -1 sprites/oneway.png 8bpp  98    8  24  16 -12  -8 normal
 
   -1 sprites/oneway.png 8bpp 130    8  24  16 -12  -8 normal
 
   -1 sprites/oneway.png 8bpp 162    8  24  16 -12  -8 normal
 
   -1 sprites/oneway.png 8bpp 194    8  24  16 -12  -8 normal
 
   -1 * 3	 05 09 12
 
   -1 sprites/oneway.png 8bpp  34    8  24  16 -10   -9 normal
 
   -1 sprites/oneway.png 8bpp  66    8  24  16 -13   -7 normal
 
   -1 sprites/oneway.png 8bpp  98    8  24  16 -12   -8 normal
 
   -1 sprites/oneway.png 8bpp 130    8  24  16 -15  -10 normal
 
   -1 sprites/oneway.png 8bpp 162    8  24  16 -12   -9 normal
 
   -1 sprites/oneway.png 8bpp 194    8  24  16 -11   -8 normal
 

	
 
   -1 sprites/oneway.png 8bpp  34   40  24  16 -13  -10 normal
 
   -1 sprites/oneway.png 8bpp  66   40  24  16 -12   -8 normal
 
   -1 sprites/oneway.png 8bpp  98   40  24  16 -12   -9 normal
 
   -1 sprites/oneway.png 8bpp 130   40  24  16 -11   -8 normal
 
   -1 sprites/oneway.png 8bpp 162   40  24  16  -9  -10 normal
 
   -1 sprites/oneway.png 8bpp 194   40  24  16 -10   -9 normal
 

	
 
   -1 sprites/oneway.png 8bpp  34   72  24  16  -8  -11 normal
 
   -1 sprites/oneway.png 8bpp  66   72  24  16 -11   -5 normal
 
   -1 sprites/oneway.png 8bpp  98   72  24  16 -12   -8 normal
 
   -1 sprites/oneway.png 8bpp 130   72  24  16 -12   -5 normal
 
   -1 sprites/oneway.png 8bpp 162   72  24  16 -14  -10 normal
 
   -1 sprites/oneway.png 8bpp 194   72  24  16 -12   -8 normal
media/baseset/openttd/oneway.png
Show inline comments
 
binary diff not shown
Show images
src/newgrf.cpp
Show inline comments
 
@@ -6274,9 +6274,17 @@ static void GraphicsNew(ByteReader *buf)
 
		if (offset <= depot_no_track_offset && offset + num > depot_no_track_offset) _loaded_newgrf_features.tram = TRAMWAY_REPLACE_DEPOT_NO_TRACK;
 
	}
 

	
 
	/* If the baseset or grf only provides sprites for flat tiles (pre #10282), duplicate those for use on slopes. */
 
	bool dup_oneway_sprites = ((type == 0x09) && (offset + num <= SPR_ONEWAY_SLOPE_N_OFFSET));
 

	
 
	for (; num > 0; num--) {
 
		_cur.nfo_line++;
 
		LoadNextSprite(replace == 0 ? _cur.spriteid++ : replace++, *_cur.file, _cur.nfo_line);
 
		int load_index = (replace == 0 ? _cur.spriteid++ : replace++);
 
		LoadNextSprite(load_index, *_cur.file, _cur.nfo_line);
 
		if (dup_oneway_sprites) {
 
			DupSprite(load_index, load_index + SPR_ONEWAY_SLOPE_N_OFFSET);
 
			DupSprite(load_index, load_index + SPR_ONEWAY_SLOPE_S_OFFSET);
 
		}
 
	}
 

	
 
	_cur.skip_sprites = skip_num;
src/road.h
Show inline comments
 
@@ -66,6 +66,7 @@ enum RoadTypeSpriteGroup {
 
	ROTSG_DEPOT,          ///< Optional: Depot images
 
	ROTSG_reserved3,      ///<           Placeholder, if we add road fences (for highways).
 
	ROTSG_ROADSTOP,       ///< Required: Drive-in stop surface
 
	ROTSG_ONEWAY,         ///< Optional: One-way indicator images
 
	ROTSG_END,
 
};
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -1606,7 +1606,17 @@ static void DrawRoadBits(TileInfo *ti)
 
	if (road_rti != nullptr) {
 
		DisallowedRoadDirections drd = GetDisallowedRoadDirections(ti->tile);
 
		if (drd != DRD_NONE) {
 
			DrawGroundSpriteAt(SPR_ONEWAY_BASE + drd - 1 + ((road == ROAD_X) ? 0 : 3), PAL_NONE, 8, 8, GetPartialPixelZ(8, 8, ti->tileh));
 
			SpriteID oneway = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_ONEWAY);
 

	
 
			if (oneway == 0) oneway = SPR_ONEWAY_BASE;
 

	
 
			if ((ti->tileh == SLOPE_NE) || (ti->tileh == SLOPE_NW)) {
 
				oneway += SPR_ONEWAY_SLOPE_N_OFFSET;
 
			} else if ((ti->tileh == SLOPE_SE) || (ti->tileh == SLOPE_SW)) {
 
				oneway += SPR_ONEWAY_SLOPE_S_OFFSET;
 
			}
 

	
 
			DrawGroundSpriteAt(oneway + drd - 1 + ((road == ROAD_X) ? 0 : 3), PAL_NONE, 8, 8, GetPartialPixelZ(8, 8, ti->tileh));
 
		}
 
	}
 

	
src/table/sprites.h
Show inline comments
 
@@ -290,8 +290,10 @@ static const SpriteID SPR_TRAMWAY_DEPOT_
 
static const uint16 TRAMWAY_SPRITE_COUNT = 119;
 

	
 
/** One way road sprites */
 
static const SpriteID SPR_ONEWAY_BASE = SPR_TRAMWAY_BASE + TRAMWAY_SPRITE_COUNT;
 
static const uint16 ONEWAY_SPRITE_COUNT = 6;
 
static const SpriteID SPR_ONEWAY_BASE           = SPR_TRAMWAY_BASE + TRAMWAY_SPRITE_COUNT;
 
static const SpriteID SPR_ONEWAY_SLOPE_N_OFFSET = 6;
 
static const SpriteID SPR_ONEWAY_SLOPE_S_OFFSET = 12;
 
static const uint16 ONEWAY_SPRITE_COUNT = 18;
 

	
 
/** Tunnel sprites with grass only for custom railtype tunnel. */
 
static const SpriteID SPR_RAILTYPE_TUNNEL_BASE = SPR_ONEWAY_BASE + ONEWAY_SPRITE_COUNT;
0 comments (0 inline, 0 general)