waypoint.c
changeset 3764 f017ce73e96b
parent 3751 ce6408fdb788
child 3792 67c865c9315c
equal deleted inserted replaced
3763:7098c393c172 3764:f017ce73e96b
    13 #include "station.h"
    13 #include "station.h"
    14 #include "tile.h"
    14 #include "tile.h"
    15 #include "town.h"
    15 #include "town.h"
    16 #include "waypoint.h"
    16 #include "waypoint.h"
    17 #include "variables.h"
    17 #include "variables.h"
    18 #include "table/sprites.h"
       
    19 #include "table/strings.h"
    18 #include "table/strings.h"
    20 #include "vehicle.h"
    19 #include "vehicle.h"
    21 
    20 
    22 enum {
    21 enum {
    23 	/* Max waypoints: 64000 (8 * 8000) */
    22 	/* Max waypoints: 64000 (8 * 8000) */
   377 	stat.build_date = wp->build_date;
   376 	stat.build_date = wp->build_date;
   378 
   377 
   379 	return &stat;
   378 	return &stat;
   380 }
   379 }
   381 
   380 
   382 extern uint16 _custom_sprites_base;
       
   383 
       
   384 
       
   385 /* Draw a waypoint */
   381 /* Draw a waypoint */
   386 void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
   382 void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
   387 {
   383 {
   388 	const StationSpec *statspec;
       
   389 	uint32 relocation;
       
   390 	const DrawTileSprites *cust;
       
   391 	DrawTileSeqStruct const *seq;
       
   392 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
       
   393 	uint32 ormod, img;
       
   394 
       
   395 	ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player));
       
   396 
       
   397 	x += 33;
   384 	x += 33;
   398 	y += 17;
   385 	y += 17;
   399 
   386 
   400 	statspec = GetCustomStationSpec(STAT_CLASS_WAYP, stat_id);
   387 	if (!DrawStationTile(x, y, railtype, AXIS_X, STAT_CLASS_WAYP, stat_id)) {
   401 	if (statspec == NULL) {
       
   402 		// stat is NULL for default waypoints and when waypoint graphics are
       
   403 		// not loaded.
       
   404 		DrawDefaultWaypointSprite(x, y, railtype);
   388 		DrawDefaultWaypointSprite(x, y, railtype);
   405 		return;
       
   406 	}
       
   407 
       
   408 	relocation = GetCustomStationRelocation(statspec, NULL, INVALID_TILE);
       
   409 	// emulate station tile - open with building
       
   410 	// add 1 to get the other direction
       
   411 	cust = &statspec->renderdata[2];
       
   412 
       
   413 	img = cust->ground_sprite;
       
   414 	img += (img < _custom_sprites_base) ? rti->total_offset : rti->custom_ground_offset;
       
   415 
       
   416 	if (img & PALETTE_MODIFIER_COLOR) img = (img & SPRITE_MASK);
       
   417 	DrawSprite(img, x, y);
       
   418 
       
   419 	foreach_draw_tile_seq(seq, cust->seq) {
       
   420 		Point pt = RemapCoords(seq->delta_x, seq->delta_y, seq->delta_z);
       
   421 		uint32 image = seq->image + relocation;
       
   422 		DrawSprite((image & SPRITE_MASK) | ormod, x + pt.x, y + pt.y);
       
   423 	}
   389 	}
   424 }
   390 }
   425 
   391 
   426 /* Fix savegames which stored waypoints in their old format */
   392 /* Fix savegames which stored waypoints in their old format */
   427 void FixOldWaypoints(void)
   393 void FixOldWaypoints(void)