diff options
author | tron <tron@openttd.org> | 2006-04-25 07:29:02 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-04-25 07:29:02 +0000 |
commit | df3d8d33ec3f1c891a479a9c286fe0f0bdbfd7f5 (patch) | |
tree | 74d64de1d1689cf7573a3244fa9105084f3b8acf | |
parent | 4dc68326d911f8e8937a37e1222577452adba9d2 (diff) | |
download | openttd-df3d8d33ec3f1c891a479a9c286fe0f0bdbfd7f5.tar.xz |
(svn r4571) Change the rail type update for electrified rails so it doesn't use bit magic
-rw-r--r-- | openttd.c | 29 |
1 files changed, 20 insertions, 9 deletions
@@ -1082,6 +1082,13 @@ static void UpdateSignOwner(void) extern void UpdateOldAircraft( void ); extern void UpdateOilRig( void ); + +static inline RailType UpdateRailType(RailType rt, RailType min) +{ + return rt >= min ? (RailType)(rt + 1): rt; +} + + bool AfterLoadGame(void) { Window *w; @@ -1247,7 +1254,7 @@ bool AfterLoadGame(void) Vehicle* v; uint i; TileIndex t; - bool make_elrail = false; + RailType min_rail = RAILTYPE_ELECTRIC; for (i = 0; i < lengthof(_engines); i++) { Engine* e = GetEngine(i); @@ -1262,7 +1269,7 @@ bool AfterLoadGame(void) RailType rt = GetEngine(v->engine_type)->railtype; v->u.rail.railtype = rt; - if (rt == RAILTYPE_ELECTRIC) make_elrail = true; + if (rt == RAILTYPE_ELECTRIC) min_rail = RAILTYPE_RAIL; } } @@ -1270,34 +1277,38 @@ bool AfterLoadGame(void) for (t = 0; t < MapSize(); t++) { switch (GetTileType(t)) { case MP_RAILWAY: - if (GetRailType(t) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 0, 4, 1); + SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); break; case MP_STREET: - if (IsLevelCrossing(t) && (GetRailTypeCrossing(t) > RAILTYPE_RAIL || make_elrail)) AB(_m[t].m4, 0, 4, 1); + if (IsLevelCrossing(t)) { + SetRailTypeCrossing(t, UpdateRailType(GetRailTypeCrossing(t), min_rail)); + } break; case MP_STATION: - if (IsRailwayStation(t) && (GetRailType(t) > RAILTYPE_RAIL || make_elrail)) AB(_m[t].m3, 0, 4, 1); + if (IsRailwayStation(t)) { + SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); + } break; case MP_TUNNELBRIDGE: if (IsTunnel(t)) { if (GetTunnelTransportType(t) == TRANSPORT_RAIL) { - if (GetRailType(t) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 0, 4, 1); + SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); } } else { if (GetBridgeTransportType(t) == TRANSPORT_RAIL) { if (IsBridgeRamp(t)) { - if (GetRailType(t) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 0, 4, 1); + SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); } else { - if (GetRailTypeOnBridge(t) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 4, 4, 1); + SetRailTypeOnBridge(t, UpdateRailType(GetRailTypeOnBridge(t), min_rail)); } } if (IsBridgeMiddle(t) && IsTransportUnderBridge(t) && GetTransportTypeUnderBridge(t) == TRANSPORT_RAIL) { - if (GetRailType(t) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 0, 4, 1); + SetRailType(t, UpdateRailType(GetRailType(t), min_rail)); } } break; |