Loading

Paste #pbiz8js5r

  1. diff --git a/src/road_map.h b/src/road_map.h
  2. index ca233ad..e456466 100644
  3. --- a/src/road_map.h
  4. +++ b/src/road_map.h
  5. @@ -159,38 +159,6 @@ static inline void SetRoadBits(TileIndex t, RoadBits r, RoadType rt)
  6.  }
  7.  
  8.  /**
  9. - * Get the present road types of a tile.
  10. - * @param t The tile to query.
  11. - * @return Present road types.
  12. - */
  13. -static inline RoadTypes GetRoadTypes(TileIndex t)
  14. -{
  15. -   return (RoadTypes)GB(_me[t].m7, 6, 2);
  16. -}
  17. -
  18. -/**
  19. - * Set the present road types of a tile.
  20. - * @param t  The tile to change.
  21. - * @param rt The new road types.
  22. - */
  23. -static inline void SetRoadTypes(TileIndex t, RoadTypes rt)
  24. -{
  25. -   assert(IsTileType(t, MP_ROAD) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE));
  26. -   SB(_me[t].m7, 6, 2, rt);
  27. -}
  28. -
  29. -/**
  30. - * Check if a tile has a specific road type.
  31. - * @param t  The tile to check.
  32. - * @param rt Road type to check.
  33. - * @return True if the tile has the specified road type.
  34. - */
  35. -static inline bool HasTileRoadType(TileIndex t, RoadType rt)
  36. -{
  37. -   return HasBit(GetRoadTypes(t), rt);
  38. -}
  39. -
  40. -/**
  41.   * Get the owner of a specific road type.
  42.   * @param t  The tile to query.
  43.   * @param rt The road type to get the owner of.
  44. @@ -565,24 +533,8 @@ struct RoadTypeIdentifiers {
  45.         assert(IsTileType(t, MP_ROAD) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE));
  46.  
  47.         RoadTypeIdentifiers rtids;
  48. -
  49. -       switch (GetTileType(t)) {
  50. -           default: NOT_REACHED();
  51. -           case MP_ROAD:
  52. -               if (HasTileRoadType(t, ROADTYPE_ROAD)) {
  53. -                   rtids.road_identifier = GetRoadTypeRoad(t);
  54. -               }
  55. -
  56. -               if (HasTileRoadType(t, ROADTYPE_TRAM)) {
  57. -                   rtids.tram_identifier = GetRoadTypeTram(t);
  58. -               }
  59. -               break;
  60. -           case MP_STATION: /* TODO */
  61. -           case MP_TUNNELBRIDGE:
  62. -               rtids.road_identifier = GetRoadTypeRoad(t);
  63. -               rtids.tram_identifier = GetRoadTypeTram(t);
  64. -               break;
  65. -       }
  66. +       rtids.road_identifier = GetRoadTypeRoad(t);
  67. +       rtids.tram_identifier = GetRoadTypeTram(t);
  68.  
  69.         return rtids;
  70.     }
  71. @@ -714,15 +666,8 @@ static inline RoadTypeIdentifiers CombineTileRoadTypeIds(TileIndex tile, RoadTyp
  72.   */
  73.  static inline void SetRoadTypes(TileIndex t, RoadTypeIdentifiers rtids)
  74.  {
  75. -   SetRoadTypes(t, rtids.PresentRoadTypes());
  76. -
  77. -   if (rtids.road_identifier.IsValid()) {
  78. -       SB(_m[t].m4, 0, 4, rtids.road_identifier.subtype);
  79. -   }
  80. -
  81. -   if (rtids.tram_identifier.IsValid()) {
  82. -       SB(_m[t].m4, 4, 4, rtids.tram_identifier.subtype);
  83. -   }
  84. +   SB(_m[t].m4, 0, 4, rtids.road_identifier.subtype);
  85. +   SB(_m[t].m4, 4, 4, rtids.tram_identifier.subtype);
  86.  }
  87.  
  88.  static inline bool HasRoadTypeRoad(TileIndex t)
  89. @@ -764,16 +709,17 @@ static inline bool HasRoadTypeTram(RoadTypeIdentifiers rtids)
  90.   * @param road New owner of road.
  91.   * @param tram New owner of tram tracks.
  92.   */
  93. -static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram)
  94. +static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypeIdentifier rtid, TownID town, Owner road, Owner tram)
  95.  {
  96.     SetTileType(t, MP_ROAD);
  97.     SetTileOwner(t, road);
  98.     _m[t].m2 = town;
  99. -   _m[t].m3 = (HasBit(rot, ROADTYPE_TRAM) ? bits : 0);
  100. +   _m[t].m3 = rtid.IsTram() ? bits : 0);
  101.     _m[t].m4 = 0;
  102. -   _m[t].m5 = (HasBit(rot, ROADTYPE_ROAD) ? bits : 0) | ROAD_TILE_NORMAL << 6;
  103. +   _m[t].m5 = (rtid.IsRoad() ? bits : 0) | ROAD_TILE_NORMAL << 6;
  104.     SB(_me[t].m6, 2, 4, 0);
  105. -   _me[t].m7 = rot << 6;
  106. +   _me[t].m7 = 0;
  107. +   SetRoadTypes(RoadTypeIdentifiers::FromRoadTypeIdentifier(rtid));
  108.     SetRoadOwner(t, ROADTYPE_TRAM, tram);
  109.  }
  110.  
  111. @@ -788,7 +734,7 @@ static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, Tow
  112.   * @param rot     New present road types.
  113.   * @param town    Town ID if the road is a town-owned road.
  114.   */
  115. -static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadTypes rot, uint town)
  116. +static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadTypeIdentifier rtid, uint town)
  117.  {
  118.     SetTileType(t, MP_ROAD);
  119.     SetTileOwner(t, rail);
  120. @@ -797,7 +743,8 @@ static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner r
  121.     _m[t].m4 = 0;
  122.     _m[t].m5 = ROAD_TILE_CROSSING << 6 | roaddir;
  123.     SB(_me[t].m6, 2, 4, 0);
  124. -   _me[t].m7 = rot << 6 | road;
  125. +   _me[t].m7 = road;
  126. +   SetRoadTypes(RoadTypeIdentifiers::FromRoadTypeIdentifier(rtid));
  127.     SetRoadOwner(t, ROADTYPE_TRAM, tram);
  128.  }
  129.  
  130. @@ -818,7 +765,7 @@ static inline void MakeRoadDepot(TileIndex t, Owner owner, DepotID did, DiagDire
  131.     _m[t].m4 = 0;
  132.     _m[t].m5 = ROAD_TILE_DEPOT << 6 | dir;
  133.     SB(_me[t].m6, 2, 4, 0);
  134. -   _me[t].m7 = RoadTypeToRoadTypes(rtid.basetype) << 6 | owner;
  135. +   _me[t].m7 = owner;
  136.     SetRoadOwner(t, ROADTYPE_TRAM, owner);
  137.     SetRoadTypes(t, RoadTypeIdentifiers::FromRoadTypeIdentifier(rtid));
  138.  }
  139. @@ -838,11 +785,11 @@ static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypeIdentifier
  140.     SetTileOwner(t, road);
  141.     _m[t].m2 = town;
  142.     _m[t].m3 = (rtid.basetype == ROADTYPE_TRAM ? bits : 0);
  143. -   SetRoadTypes(t, RoadTypeIdentifiers::FromRoadTypeIdentifier(rtid));
  144.     _m[t].m5 = (rtid.basetype == ROADTYPE_ROAD ? bits : 0) | ROAD_TILE_NORMAL << 6;
  145.     SB(_me[t].m6, 2, 4, 0);
  146. -   _me[t].m7 = RoadTypeToRoadTypes(rtid.basetype) << 6;
  147. +   _me[t].m7 = 0;
  148.     SetRoadOwner(t, ROADTYPE_TRAM, tram);
  149. +   SetRoadTypes(t, RoadTypeIdentifiers::FromRoadTypeIdentifier(rtid));
  150.  }
  151.  
  152.  #endif /* ROAD_MAP_H */
  153.  

Comments