waypoint.c
changeset 3676 680dfa6336a1
parent 3636 a36cc46e754d
child 3741 92c022b64b28
equal deleted inserted replaced
3675:620c3d676459 3676:680dfa6336a1
   151 		uint i;
   151 		uint i;
   152 
   152 
   153 		if (wp->grfid == 0) continue;
   153 		if (wp->grfid == 0) continue;
   154 
   154 
   155 		for (i = 0; i < GetNumCustomStations(STAT_CLASS_WAYP); i++) {
   155 		for (i = 0; i < GetNumCustomStations(STAT_CLASS_WAYP); i++) {
   156 			const StationSpec *spec = GetCustomStation(STAT_CLASS_WAYP, i);
   156 			const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, i);
   157 			if (spec != NULL && spec->grfid == wp->grfid && spec->localidx == wp->localidx) {
   157 			if (statspec != NULL && statspec->grfid == wp->grfid && statspec->localidx == wp->localidx) {
   158 				wp->stat_id = i;
   158 				wp->stat_id = i;
   159 				break;
   159 				break;
   160 			}
   160 			}
   161 		}
   161 		}
   162 	}
   162 	}
   211 		wp->string = STR_NULL;
   211 		wp->string = STR_NULL;
   212 		wp->town_cn = 0;
   212 		wp->town_cn = 0;
   213 	}
   213 	}
   214 
   214 
   215 	if (flags & DC_EXEC) {
   215 	if (flags & DC_EXEC) {
   216 		const StationSpec *spec = NULL;
   216 		const StationSpec *statspec = NULL;
   217 		MakeRailWaypoint(tile, GetTileOwner(tile), axis, GetRailType(tile), wp->index);
   217 		MakeRailWaypoint(tile, GetTileOwner(tile), axis, GetRailType(tile), wp->index);
   218 		MarkTileDirtyByTile(tile);
   218 		MarkTileDirtyByTile(tile);
   219 
   219 
   220 		if (GB(p1, 0, 8) < GetNumCustomStations(STAT_CLASS_WAYP))
   220 		if (GB(p1, 0, 8) < GetNumCustomStations(STAT_CLASS_WAYP))
   221 			spec = GetCustomStation(STAT_CLASS_WAYP, GB(p1, 0, 8));
   221 			statspec = GetCustomStationSpec(STAT_CLASS_WAYP, GB(p1, 0, 8));
   222 
   222 
   223 		if (spec != NULL) {
   223 		if (statspec != NULL) {
   224 			SetCustomWaypointSprite(tile);
   224 			SetCustomWaypointSprite(tile);
   225 			wp->stat_id = GB(p1, 0, 8);
   225 			wp->stat_id = GB(p1, 0, 8);
   226 			wp->grfid = spec->grfid;
   226 			wp->grfid = statspec->grfid;
   227 			wp->localidx = spec->localidx;
   227 			wp->localidx = statspec->localidx;
   228 		} else {
   228 		} else {
   229 			// Specified custom graphics do not exist, so use default.
   229 			// Specified custom graphics do not exist, so use default.
   230 			ClearCustomWaypointSprite(tile);
   230 			ClearCustomWaypointSprite(tile);
   231 			wp->stat_id = 0;
   231 			wp->stat_id = 0;
   232 			wp->grfid = 0;
   232 			wp->grfid = 0;
   383 
   383 
   384 
   384 
   385 /* Draw a waypoint */
   385 /* Draw a waypoint */
   386 void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
   386 void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
   387 {
   387 {
   388 	const StationSpec *stat;
   388 	const StationSpec *statspec;
   389 	uint32 relocation;
   389 	uint32 relocation;
   390 	const DrawTileSprites *cust;
   390 	const DrawTileSprites *cust;
   391 	DrawTileSeqStruct const *seq;
   391 	DrawTileSeqStruct const *seq;
   392 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
   392 	const RailtypeInfo *rti = GetRailTypeInfo(railtype);
   393 	uint32 ormod, img;
   393 	uint32 ormod, img;
   395 	ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player));
   395 	ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player));
   396 
   396 
   397 	x += 33;
   397 	x += 33;
   398 	y += 17;
   398 	y += 17;
   399 
   399 
   400 	stat = GetCustomStation(STAT_CLASS_WAYP, stat_id);
   400 	statspec = GetCustomStationSpec(STAT_CLASS_WAYP, stat_id);
   401 	if (stat == NULL) {
   401 	if (statspec == NULL) {
   402 		// stat is NULL for default waypoints and when waypoint graphics are
   402 		// stat is NULL for default waypoints and when waypoint graphics are
   403 		// not loaded.
   403 		// not loaded.
   404 		DrawDefaultWaypointSprite(x, y, railtype);
   404 		DrawDefaultWaypointSprite(x, y, railtype);
   405 		return;
   405 		return;
   406 	}
   406 	}
   407 
   407 
   408 	relocation = GetCustomStationRelocation(stat, NULL, 1);
   408 	relocation = GetCustomStationRelocation(statspec, NULL, 1);
   409 	// emulate station tile - open with building
   409 	// emulate station tile - open with building
   410 	// add 1 to get the other direction
   410 	// add 1 to get the other direction
   411 	cust = &stat->renderdata[2];
   411 	cust = &statspec->renderdata[2];
   412 
   412 
   413 	img = cust->ground_sprite;
   413 	img = cust->ground_sprite;
   414 	img += (img < _custom_sprites_base) ? rti->total_offset : rti->custom_ground_offset;
   414 	img += (img < _custom_sprites_base) ? rti->total_offset : rti->custom_ground_offset;
   415 
   415 
   416 	if (img & PALETTE_MODIFIER_COLOR) img = (img & SPRITE_MASK);
   416 	if (img & PALETTE_MODIFIER_COLOR) img = (img & SPRITE_MASK);