diff options
author | peter1138 <peter1138@openttd.org> | 2005-11-16 22:20:15 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2005-11-16 22:20:15 +0000 |
commit | 754d26407e8cda101f04c93a94c60bc0625f540c (patch) | |
tree | 981b72e2eee14dca280a68f1b688ab83202c9f73 /openttd.c | |
parent | 5cb9de35d114cf1f7b92945924c9fc05fa117d47 (diff) | |
download | openttd-754d26407e8cda101f04c93a94c60bc0625f540c.tar.xz |
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
- Waypoints: Until now stat_id was saved but never assigned to. Instead we now save the GRFID/local index of the custom graphics so that GRF file changes can leave graphics intact.
Diffstat (limited to 'openttd.c')
-rw-r--r-- | openttd.c | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -1287,6 +1287,43 @@ bool AfterLoadGame(uint version) } } + /* In version 17, ground type is moved from m2 to m4 for depots and + * waypoints to make way for storing the index in m2. The custom graphics + * id which was stored in m4 is now saved as a grf/id reference in the + * waypoint struct. */ + if (version < 0x1100) { + Waypoint *wp; + + FOR_ALL_WAYPOINTS(wp) { + if (wp->xy != 0 && wp->deleted == 0) { + const StationSpec *spec = NULL; + + if (HASBIT(_m[wp->xy].m3, 4)) + spec = GetCustomStation(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1); + + if (spec != NULL) { + wp->stat_id = _m[wp->xy].m4 + 1; + wp->grfid = spec->grfid; + wp->localidx = spec->localidx; + } else { + // No custom graphics set, so set to default. + wp->stat_id = 0; + wp->grfid = 0; + wp->localidx = 0; + } + + // Move ground type bits from m2 to m4. + _m[wp->xy].m4 = GB(_m[wp->xy].m2, 0, 4); + // Store waypoint index in the tile. + _m[wp->xy].m2 = wp->index; + } + } + } else { + /* As of version 17, we recalculate the custom graphic ID of waypoints + * from the GRF ID / station index. */ + UpdateAllWaypointCustomGraphics(); + } + FOR_ALL_PLAYERS(p) p->avail_railtypes = GetPlayerRailtypes(p->index); return true; |