diff --git a/src/newgrf_roadtype.cpp b/src/newgrf_roadtype.cpp index ddacaaf..64eaeca 100644 --- a/src/newgrf_roadtype.cpp +++ b/src/newgrf_roadtype.cpp @@ -131,7 +131,7 @@ uint8 GetReverseRoadTypeTranslation(RoadTypeIdentifier rti, const GRFFile *grffi if (grffile == NULL || grffile->roadtype_list.Length() == 0) return rti.subtype; /* Look for a matching road type label in the table */ - RoadTypeLabel label = GetRoadTypeInfo(rti.Pack())->label; + RoadTypeLabel label = GetRoadTypeInfo(rti)->label; int index = grffile->roadtype_list.FindIndex(label); if (index >= 0) return index; diff --git a/src/road.cpp b/src/road.cpp index 29337f5..c4a5a83 100644 --- a/src/road.cpp +++ b/src/road.cpp @@ -169,7 +169,7 @@ RoadTypeIdentifier GetRoadTypeByLabel(RoadTypeLabel label, RoadType basetype, bo /* Loop through each road type until the label is found */ for (RoadSubType r = ROADSUBTYPE_BEGIN; r != ROADSUBTYPE_END; r++) { rtid.subtype = r; - const RoadtypeInfo *rti = GetRoadTypeInfo(rtid.Pack()); + const RoadtypeInfo *rti = GetRoadTypeInfo(rtid); if (rti->label == label) return rtid; } @@ -177,7 +177,7 @@ RoadTypeIdentifier GetRoadTypeByLabel(RoadTypeLabel label, RoadType basetype, bo /* Test if any road type defines the label as an alternate. */ for (RoadSubType r = ROADSUBTYPE_BEGIN; r != ROADSUBTYPE_END; r++) { rtid.subtype = r; - const RoadtypeInfo *rti = GetRoadTypeInfo(rtid.Pack()); + const RoadtypeInfo *rti = GetRoadTypeInfo(rtid); if (rti->alternate_labels.Contains(label)) return rtid; } } @@ -222,4 +222,4 @@ RoadTypeIdentifier::RoadTypeIdentifier(uint8 data) { bool ret = this->Unpack(data); assert(ret); -} \ No newline at end of file +} diff --git a/src/road.h b/src/road.h index 6feb34a..dbc8be6 100644 --- a/src/road.h +++ b/src/road.h @@ -216,7 +216,7 @@ struct RoadTypeIdentifier { bool IsTram(); RoadTypeIdentifier(RoadType basetype, RoadSubType subtype) : basetype(basetype), subtype(subtype) {} - RoadTypeIdentifier(uint8 data = 0); + explicit RoadTypeIdentifier(uint8 data); }; /** diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index bc45cb9..e56450e 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -638,7 +638,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 /* do not allow building 'zero' road bits, code wouldn't handle it */ if (pieces == ROAD_NONE) return CMD_ERROR; - RoadTypeIdentifier rtid = GB(p1, 4, 5); + RoadTypeIdentifier rtid(GB(p1, 4, 5)); RoadType rt = rtid.basetype; if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR; @@ -1886,13 +1886,13 @@ static void GetTileDesc_Road(TileIndex tile, TileDesc *td) const RoadtypeInfo *rti; if (rtids.road_identifier.IsValid()) { - rti = GetRoadTypeInfo(rtids.road_identifier.Pack()); + rti = GetRoadTypeInfo(rtids.road_identifier); td->str = rti->strings.menu_text; // TODO: roadside strings from grf road_owner = GetRoadOwner(tile, ROADTYPE_ROAD); } if (rtids.tram_identifier.IsValid()) { - rti = GetRoadTypeInfo(rtids.tram_identifier.Pack()); + rti = GetRoadTypeInfo(rtids.tram_identifier); td->str = rti->strings.menu_text; // TODO: roadside strings from grf tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM); } diff --git a/src/road_func.h b/src/road_func.h index ee6665e..ecb28ea 100644 --- a/src/road_func.h +++ b/src/road_func.h @@ -179,7 +179,7 @@ static inline Money RoadMaintenanceCost(RoadType roadtype, uint32 num) static inline bool HasCatenary(RoadTypeIdentifier rti) { assert(IsValidRoadType(rti.basetype)); - return HasBit(GetRoadTypeInfo(rti.Pack())->flags, ROTF_CATENARY); + return HasBit(GetRoadTypeInfo(rti)->flags, ROTF_CATENARY); } bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts); diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 25c3190..8907269 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -334,9 +334,9 @@ struct BuildRoadToolbarWindow : Window { * Switch to another road type. * @param roadtype New road type. */ - void ModifyRoadType(RoadType roadtype) + void ModifyRoadType(RoadTypeIdentifier roadtype_identifier) { - this->SetupRoadToolbar(roadtype); + this->SetupRoadToolbar(roadtype_identifier); this->ReInit(); } @@ -847,7 +847,7 @@ Window *ShowBuildRoadScenToolbar() { _cur_roadtype_identifier = RoadTypeIdentifier(ROADTYPE_ROAD, ROADSUBTYPE_BEGIN); //return AllocateWindowDescFront(&_build_road_scen_desc, TRANSPORT_ROAD); - return new BuildRoadToolbarWindow(&_build_road_scen_desc, ROADTYPE_ROAD); + return new BuildRoadToolbarWindow(&_build_road_scen_desc, RoadTypeIdentifier(ROADTYPE_ROAD, ROADSUBTYPE_BEGIN)); // TODO which roadtype? } struct BuildRoadDepotWindow : public PickerWindowBase { @@ -1117,7 +1117,7 @@ void InitializeRoadGui() void InitializeRoadGUI() { BuildRoadToolbarWindow *w = dynamic_cast(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_ROAD)); - if (w != NULL) w->ModifyRoadType(_cur_roadtype_identifier.basetype); + if (w != NULL) w->ModifyRoadType(_cur_roadtype_identifier); } DropDownList *GetRoadTypeDropDownList(RoadType roadtype) diff --git a/src/road_map.h b/src/road_map.h index 73f817d..f4ce73c 100644 --- a/src/road_map.h +++ b/src/road_map.h @@ -770,11 +770,11 @@ struct RoadTypeIdentifiers { bool HasCatenary() { - if (road_identifier.IsValid() && GetRoadTypeInfo(road_identifier.Pack())->flags & ROTFB_CATENARY) { + if (road_identifier.IsValid() && GetRoadTypeInfo(road_identifier)->flags & ROTFB_CATENARY) { return true; } - if (tram_identifier.IsValid() && GetRoadTypeInfo(tram_identifier.Pack())->flags & ROTFB_CATENARY) { + if (tram_identifier.IsValid() && GetRoadTypeInfo(tram_identifier)->flags & ROTFB_CATENARY) { return true; }