diff --git a/docs/newgrf-additions.html b/docs/newgrf-additions.html index 75bd4a1bf0..62d28efc1a 100644 --- a/docs/newgrf-additions.html +++ b/docs/newgrf-additions.html @@ -231,6 +231,17 @@

This is indicated by the feature name: action0_railtype_restricted_signals, version 1


+

Action 0 - Roadtypes and Action 0 - Tramtypes

+

Extra road/tram type flags (mappable property: roadtype_extra_flags)

+

This property sets the extra flags for this road/tram type.
+ The property length is 1 byte. The format is: + + + +
BitValueMeaning
01Scripts (AI/GS) may not build this road/tram type
+

+

This is indicated by the feature name: action0_roadtype_extra_flags, version 1

+

Variational Action 2 - Stations

Track type in purchase list (42)

This is indicated by the feature name: varaction2_station_var42, version 1

diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 6fd1348f3f..b04320d8c0 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -4568,6 +4568,11 @@ static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, const for (int j = buf->ReadByte(); j != 0; j--) buf->ReadDWord(); break; + case A0RPI_ROADTYPE_EXTRA_FLAGS: + if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; + rti->extra_flags = (RoadTypeExtraFlags)buf->ReadByte(); + break; + default: ret = CIR_UNKNOWN; break; @@ -8381,6 +8386,7 @@ static const GRFFeatureInfo _grf_feature_list[] = { GRFFeatureInfo("action5_programmable_signals", 1), GRFFeatureInfo("action0_railtype_programmable_signals", 1), GRFFeatureInfo("action0_railtype_restricted_signals", 1), + GRFFeatureInfo("action0_roadtype_extra_flags", 1), GRFFeatureInfo(), }; @@ -8499,6 +8505,8 @@ static const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = { GRFPropertyMapDefinition(GSF_BRIDGES, A0RPI_BRIDGE_AVAILABILITY_FLAGS, "bridge_availability_flags"), GRFPropertyMapDefinition(GSF_RAILTYPES, A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS, "railtype_enable_programmable_signals"), GRFPropertyMapDefinition(GSF_RAILTYPES, A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS, "railtype_enable_restricted_signals"), + GRFPropertyMapDefinition(GSF_ROADTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"), + GRFPropertyMapDefinition(GSF_TRAMTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"), GRFPropertyMapDefinition(), }; diff --git a/src/newgrf.h b/src/newgrf.h index c319d0ab5a..44f9f410ee 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -117,6 +117,7 @@ enum Action0RemapPropertyIds { A0RPI_BRIDGE_AVAILABILITY_FLAGS, A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS, A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS, + A0RPI_ROADTYPE_EXTRA_FLAGS, }; enum GRFPropertyMapFallbackMode { diff --git a/src/road.h b/src/road.h index 1082ab2729..b1924ded75 100644 --- a/src/road.h +++ b/src/road.h @@ -51,6 +51,15 @@ enum RoadTypeFlags { }; DECLARE_ENUM_AS_BIT_SET(RoadTypeFlags) +/** Roadtype extra flags. */ +enum RoadTypeExtraFlags { + RXTF_NOT_AVAILABLE_AI_GS = 0, ///< Bit number for unavailable for AI/GS + + RXTFB_NONE = 0, ///< All flags cleared. + RXTFB_NOT_AVAILABLE_AI_GS = 1 << RXTF_NOT_AVAILABLE_AI_GS, ///< Value for unavailable for AI/GS +}; +DECLARE_ENUM_AS_BIT_SET(RoadTypeExtraFlags) + struct SpriteGroup; /** Sprite groups for a roadtype. */ @@ -123,6 +132,11 @@ public: */ RoadTypeFlags flags; + /** + * Bit mask of road type extra flags + */ + RoadTypeExtraFlags extra_flags; + /** * Cost multiplier for building this road type */ diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 670a2b918b..afa477e998 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -70,7 +70,7 @@ void ResetRoadTypes() { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, {}, {}, 0, {}, {} }, - ROADTYPES_NONE, ROTFB_NONE, 0, 0, 0, 0, + ROADTYPES_NONE, ROTFB_NONE, RXTFB_NONE, 0, 0, 0, 0, RoadTypeLabelList(), 0, 0, ROADTYPES_NONE, ROADTYPES_NONE, 0, {}, {} }; for (; i < lengthof(_roadtypes); i++) _roadtypes[i] = empty_roadtype; @@ -146,6 +146,7 @@ RoadType AllocateRoadType(RoadTypeLabel label, RoadTramType rtt) rti->label = label; rti->alternate_labels.clear(); rti->flags = ROTFB_NONE; + rti->extra_flags = RXTFB_NONE; rti->introduction_date = INVALID_DATE; /* Make us compatible with ourself. */ diff --git a/src/script/api/script_road.cpp b/src/script/api/script_road.cpp index e1549b0d77..5d2acb0e95 100644 --- a/src/script/api/script_road.cpp +++ b/src/script/api/script_road.cpp @@ -63,7 +63,7 @@ /* static */ bool ScriptRoad::IsRoadTypeAvailable(RoadType road_type) { - return (::RoadType)road_type < ROADTYPE_END && ::HasRoadTypeAvail(ScriptObject::GetCompany(), (::RoadType)road_type); + return (::RoadType)road_type < ROADTYPE_END && ::HasRoadTypeAvail(ScriptObject::GetCompany(), (::RoadType)road_type) && !HasBit(GetRoadTypeInfo((::RoadType)road_type)->extra_flags, RXTF_NOT_AVAILABLE_AI_GS); } /* static */ ScriptRoad::RoadType ScriptRoad::GetCurrentRoadType() diff --git a/src/script/api/script_roadtypelist.cpp b/src/script/api/script_roadtypelist.cpp index 6ada0cb6b3..f49f763371 100644 --- a/src/script/api/script_roadtypelist.cpp +++ b/src/script/api/script_roadtypelist.cpp @@ -17,6 +17,9 @@ ScriptRoadTypeList::ScriptRoadTypeList(ScriptRoad::RoadTramTypes rtts) { for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) { if (!HasBit(rtts, GetRoadTramType(rt))) continue; - if (ScriptObject::GetCompany() == OWNER_DEITY || ::HasRoadTypeAvail(ScriptObject::GetCompany(), rt)) this->AddItem(rt); + if (ScriptObject::GetCompany() == OWNER_DEITY || ::HasRoadTypeAvail(ScriptObject::GetCompany(), rt) && + !HasBit(GetRoadTypeInfo(rt)->extra_flags, RXTF_NOT_AVAILABLE_AI_GS)) { + this->AddItem(rt); + } } } diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index e8eabc028a..3052813060 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -861,6 +861,9 @@ class NIHRoadType : public NIHelper { HasBit(rti->flags, ROTF_HIDDEN) ? 'h' : '-', HasBit(rti->flags, ROTF_TOWN_BUILD) ? 'T' : '-'); print(buffer); + seprintf(buffer, lastof(buffer), " Extra Flags: %c", + HasBit(rti->extra_flags, RXTF_NOT_AVAILABLE_AI_GS) ? 's' : '-'); + print(buffer); seprintf(buffer, lastof(buffer), " Powered: 0x" OTTD_PRINTFHEX64, rti->powered_roadtypes); print(buffer); }; diff --git a/src/table/roadtypes.h b/src/table/roadtypes.h index d11573d632..c98f55a2e9 100644 --- a/src/table/roadtypes.h +++ b/src/table/roadtypes.h @@ -63,6 +63,9 @@ static const RoadTypeInfo _original_roadtypes[] = { /* flags */ ROTFB_TOWN_BUILD, + /* extra flags */ + RXTFB_NONE, + /* cost multiplier */ 8, @@ -143,6 +146,9 @@ static const RoadTypeInfo _original_roadtypes[] = { /* flags */ ROTFB_CATENARY | ROTFB_NO_HOUSES, + /* extra flags */ + RXTFB_NONE, + /* cost multiplier */ 16,