File diff r3046:6457665c9b5a → r3047:7f6140318561
waypoint.c
Show inline comments
 
@@ -404,91 +404,91 @@ void DrawWaypointSprite(int x, int y, in
 
		return;
 
	}
 

	
 
	relocation = GetCustomStationRelocation(stat, NULL, 1);
 
	// emulate station tile - open with building
 
	// add 1 to get the other direction
 
	cust = &stat->renderdata[2];
 

	
 
	img = cust->ground_sprite;
 
	img += (img < _custom_sprites_base) ? rti->total_offset : railtype;
 

	
 
	if (img & PALETTE_MODIFIER_COLOR) img = (img & SPRITE_MASK);
 
	DrawSprite(img, x, y);
 

	
 
	foreach_draw_tile_seq(seq, cust->seq) {
 
		Point pt = RemapCoords(seq->delta_x, seq->delta_y, seq->delta_z);
 
		uint32 image = seq->image + relocation;
 
		DrawSprite((image & SPRITE_MASK) | ormod, x + pt.x, y + pt.y);
 
	}
 
}
 

	
 
/* Fix savegames which stored waypoints in their old format */
 
void FixOldWaypoints(void)
 
{
 
	Waypoint *wp;
 

	
 
	/* Convert the old 'town_or_string', to 'string' / 'town' / 'town_cn' */
 
	FOR_ALL_WAYPOINTS(wp) {
 
		if (wp->xy == 0)
 
			continue;
 

	
 
		wp->town_index = ClosestTownFromTile(wp->xy, (uint)-1)->index;
 
		wp->town_cn = 0;
 
		if (wp->string & 0xC000) {
 
			wp->town_cn = wp->string & 0x3F;
 
			wp->string = STR_NULL;
 
		}
 
	}
 
}
 

	
 
void InitializeWaypoints(void)
 
{
 
	CleanPool(&_waypoint_pool);
 
	AddBlockToPool(&_waypoint_pool);
 
}
 

	
 
static const SaveLoad _waypoint_desc[] = {
 
	SLE_CONDVAR(Waypoint, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
 
	SLE_CONDVAR(Waypoint, xy, SLE_UINT32, 6, 255),
 
	SLE_CONDVAR(Waypoint, town_index, SLE_UINT16, 12, 255),
 
	SLE_CONDVAR(Waypoint, town_cn, SLE_UINT8, 12, 255),
 
	SLE_CONDVAR(Waypoint, xy, SLE_UINT32, 6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Waypoint, town_index, SLE_UINT16, 12, SL_MAX_VERSION),
 
	SLE_CONDVAR(Waypoint, town_cn, SLE_UINT8, 12, SL_MAX_VERSION),
 
	SLE_VAR(Waypoint, string, SLE_UINT16),
 
	SLE_VAR(Waypoint, deleted, SLE_UINT8),
 

	
 
	SLE_CONDVAR(Waypoint, build_date, SLE_UINT16,  3, 255),
 
	SLE_CONDVAR(Waypoint, localidx,   SLE_UINT8,   3, 255),
 
	SLE_CONDVAR(Waypoint, grfid,      SLE_UINT32, 17, 255),
 
	SLE_CONDVAR(Waypoint, build_date, SLE_UINT16,  3, SL_MAX_VERSION),
 
	SLE_CONDVAR(Waypoint, localidx,   SLE_UINT8,   3, SL_MAX_VERSION),
 
	SLE_CONDVAR(Waypoint, grfid,      SLE_UINT32, 17, SL_MAX_VERSION),
 

	
 
	SLE_END()
 
};
 

	
 
static void Save_WAYP(void)
 
{
 
	Waypoint *wp;
 

	
 
	FOR_ALL_WAYPOINTS(wp) {
 
		if (wp->xy != 0) {
 
			SlSetArrayIndex(wp->index);
 
			SlObject(wp, _waypoint_desc);
 
		}
 
	}
 
}
 

	
 
static void Load_WAYP(void)
 
{
 
	int index;
 

	
 
	while ((index = SlIterateArray()) != -1) {
 
		Waypoint *wp;
 

	
 
		if (!AddBlockIfNeeded(&_waypoint_pool, index))
 
			error("Waypoints: failed loading savegame: too many waypoints");
 

	
 
		wp = GetWaypoint(index);
 
		SlObject(wp, _waypoint_desc);
 
	}
 
}
 

	
 
const ChunkHandler _waypoint_chunk_handlers[] = {
 
	{ 'CHKP', Save_WAYP, Load_WAYP, CH_ARRAY | CH_LAST},
 
};