Loading

Paste #pnh7qtkyt

  1. diff --git a/src/newgrf_roadtype.cpp b/src/newgrf_roadtype.cpp
  2. index ddacaaf..64eaeca 100644
  3. --- a/src/newgrf_roadtype.cpp
  4. +++ b/src/newgrf_roadtype.cpp
  5. @@ -131,7 +131,7 @@ uint8 GetReverseRoadTypeTranslation(RoadTypeIdentifier rti, const GRFFile *grffi
  6.     if (grffile == NULL || grffile->roadtype_list.Length() == 0) return rti.subtype;
  7.  
  8.     /* Look for a matching road type label in the table */
  9. -   RoadTypeLabel label = GetRoadTypeInfo(rti.Pack())->label;
  10. +   RoadTypeLabel label = GetRoadTypeInfo(rti)->label;
  11.     int index = grffile->roadtype_list.FindIndex(label);
  12.     if (index >= 0) return index;
  13.  
  14. diff --git a/src/road.cpp b/src/road.cpp
  15. index 29337f5..c4a5a83 100644
  16. --- a/src/road.cpp
  17. +++ b/src/road.cpp
  18. @@ -169,7 +169,7 @@ RoadTypeIdentifier GetRoadTypeByLabel(RoadTypeLabel label, RoadType basetype, bo
  19.     /* Loop through each road type until the label is found */
  20.     for (RoadSubType r = ROADSUBTYPE_BEGIN; r != ROADSUBTYPE_END; r++) {
  21.         rtid.subtype = r;
  22. -       const RoadtypeInfo *rti = GetRoadTypeInfo(rtid.Pack());
  23. +       const RoadtypeInfo *rti = GetRoadTypeInfo(rtid);
  24.         if (rti->label == label) return rtid;
  25.     }
  26.  
  27. @@ -177,7 +177,7 @@ RoadTypeIdentifier GetRoadTypeByLabel(RoadTypeLabel label, RoadType basetype, bo
  28.         /* Test if any road type defines the label as an alternate. */
  29.         for (RoadSubType r = ROADSUBTYPE_BEGIN; r != ROADSUBTYPE_END; r++) {
  30.             rtid.subtype = r;
  31. -           const RoadtypeInfo *rti = GetRoadTypeInfo(rtid.Pack());
  32. +           const RoadtypeInfo *rti = GetRoadTypeInfo(rtid);
  33.             if (rti->alternate_labels.Contains(label)) return rtid;
  34.         }
  35.     }
  36. @@ -222,4 +222,4 @@ RoadTypeIdentifier::RoadTypeIdentifier(uint8 data)
  37.  {
  38.     bool ret = this->Unpack(data);
  39.     assert(ret);
  40. -}
  41. \ No newline at end of file
  42. +}
  43. diff --git a/src/road.h b/src/road.h
  44. index 6feb34a..dbc8be6 100644
  45. --- a/src/road.h
  46. +++ b/src/road.h
  47. @@ -216,7 +216,7 @@ struct RoadTypeIdentifier {
  48.     bool IsTram();
  49.  
  50.     RoadTypeIdentifier(RoadType basetype, RoadSubType subtype) : basetype(basetype), subtype(subtype) {}
  51. -   RoadTypeIdentifier(uint8 data = 0);
  52. +   explicit RoadTypeIdentifier(uint8 data);
  53.  };
  54.  
  55.  /**
  56. diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
  57. index bc45cb9..e56450e 100644
  58. --- a/src/road_cmd.cpp
  59. +++ b/src/road_cmd.cpp
  60. @@ -638,7 +638,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
  61.     /* do not allow building 'zero' road bits, code wouldn't handle it */
  62.     if (pieces == ROAD_NONE) return CMD_ERROR;
  63.  
  64. -   RoadTypeIdentifier rtid = GB(p1, 4, 5);
  65. +   RoadTypeIdentifier rtid(GB(p1, 4, 5));
  66.     RoadType rt = rtid.basetype;
  67.  
  68.     if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR;
  69. @@ -1886,13 +1886,13 @@ static void GetTileDesc_Road(TileIndex tile, TileDesc *td)
  70.             const RoadtypeInfo *rti;
  71.  
  72.             if (rtids.road_identifier.IsValid()) {
  73. -               rti = GetRoadTypeInfo(rtids.road_identifier.Pack());
  74. +               rti = GetRoadTypeInfo(rtids.road_identifier);
  75.                 td->str = rti->strings.menu_text; // TODO: roadside strings from grf
  76.                 road_owner = GetRoadOwner(tile, ROADTYPE_ROAD);
  77.             }
  78.  
  79.             if (rtids.tram_identifier.IsValid()) {
  80. -               rti = GetRoadTypeInfo(rtids.tram_identifier.Pack());
  81. +               rti = GetRoadTypeInfo(rtids.tram_identifier);
  82.                 td->str = rti->strings.menu_text; // TODO: roadside strings from grf
  83.                 tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM);
  84.             }
  85. diff --git a/src/road_func.h b/src/road_func.h
  86. index ee6665e..ecb28ea 100644
  87. --- a/src/road_func.h
  88. +++ b/src/road_func.h
  89. @@ -179,7 +179,7 @@ static inline Money RoadMaintenanceCost(RoadType roadtype, uint32 num)
  90.  static inline bool HasCatenary(RoadTypeIdentifier rti)
  91.  {
  92.     assert(IsValidRoadType(rti.basetype));
  93. -   return HasBit(GetRoadTypeInfo(rti.Pack())->flags, ROTF_CATENARY);
  94. +   return HasBit(GetRoadTypeInfo(rti)->flags, ROTF_CATENARY);
  95.  }
  96.  
  97.  bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts);
  98. diff --git a/src/road_gui.cpp b/src/road_gui.cpp
  99. index 25c3190..8907269 100644
  100. --- a/src/road_gui.cpp
  101. +++ b/src/road_gui.cpp
  102. @@ -334,9 +334,9 @@ struct BuildRoadToolbarWindow : Window {
  103.     * Switch to another road type.
  104.     * @param roadtype New road type.
  105.     */
  106. -   void ModifyRoadType(RoadType roadtype)
  107. +   void ModifyRoadType(RoadTypeIdentifier roadtype_identifier)
  108.     {
  109. -       this->SetupRoadToolbar(roadtype);
  110. +       this->SetupRoadToolbar(roadtype_identifier);
  111.         this->ReInit();
  112.     }
  113.  
  114. @@ -847,7 +847,7 @@ Window *ShowBuildRoadScenToolbar()
  115.  {
  116.     _cur_roadtype_identifier = RoadTypeIdentifier(ROADTYPE_ROAD, ROADSUBTYPE_BEGIN);
  117.     //return AllocateWindowDescFront<BuildRoadToolbarWindow>(&_build_road_scen_desc, TRANSPORT_ROAD);
  118. -   return new BuildRoadToolbarWindow(&_build_road_scen_desc, ROADTYPE_ROAD);
  119. +   return new BuildRoadToolbarWindow(&_build_road_scen_desc, RoadTypeIdentifier(ROADTYPE_ROAD, ROADSUBTYPE_BEGIN)); // TODO which roadtype?
  120.  }
  121.  
  122.  struct BuildRoadDepotWindow : public PickerWindowBase {
  123. @@ -1117,7 +1117,7 @@ void InitializeRoadGui()
  124.  void InitializeRoadGUI()
  125.  {
  126.     BuildRoadToolbarWindow *w = dynamic_cast<BuildRoadToolbarWindow *>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_ROAD));
  127. -   if (w != NULL) w->ModifyRoadType(_cur_roadtype_identifier.basetype);
  128. +   if (w != NULL) w->ModifyRoadType(_cur_roadtype_identifier);
  129.  }
  130.  
  131.  DropDownList *GetRoadTypeDropDownList(RoadType roadtype)
  132. diff --git a/src/road_map.h b/src/road_map.h
  133. index 73f817d..f4ce73c 100644
  134. --- a/src/road_map.h
  135. +++ b/src/road_map.h
  136. @@ -770,11 +770,11 @@ struct RoadTypeIdentifiers {
  137.  
  138.     bool HasCatenary()
  139.     {
  140. -       if (road_identifier.IsValid() && GetRoadTypeInfo(road_identifier.Pack())->flags & ROTFB_CATENARY) {
  141. +       if (road_identifier.IsValid() && GetRoadTypeInfo(road_identifier)->flags & ROTFB_CATENARY) {
  142.             return true;
  143.         }
  144.  
  145. -       if (tram_identifier.IsValid() && GetRoadTypeInfo(tram_identifier.Pack())->flags & ROTFB_CATENARY) {
  146. +       if (tram_identifier.IsValid() && GetRoadTypeInfo(tram_identifier)->flags & ROTFB_CATENARY) {
  147.             return true;
  148.         }
  149.  
  150.  

Comments