GRF: Add extra road/tram type flag: not available to AI/GS
This commit is contained in:
@@ -231,6 +231,17 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>This is indicated by the feature name: <font face="monospace">action0_railtype_restricted_signals</font>, version 1</p>
|
<p>This is indicated by the feature name: <font face="monospace">action0_railtype_restricted_signals</font>, version 1</p>
|
||||||
<br />
|
<br />
|
||||||
|
<h3><a href="https://newgrf-specs.tt-wiki.net/wiki/Action0/Roadtypes">Action 0 - Roadtypes</a> and <a href="https://newgrf-specs.tt-wiki.net/wiki/Action0/Tramtypes">Action 0 - Tramtypes</a></h3>
|
||||||
|
<h4>Extra road/tram type flags (mappable property: roadtype_extra_flags)</h4>
|
||||||
|
<p>This property sets the extra flags for this road/tram type.<br />
|
||||||
|
The property length is 1 byte. The format is:
|
||||||
|
<table>
|
||||||
|
<tr><th>Bit</th><th>Value</th><th>Meaning</th></tr>
|
||||||
|
<tr><td>0</td><td>1</td><td>Scripts (AI/GS) may not build this road/tram type</td></tr>
|
||||||
|
</table>
|
||||||
|
</p>
|
||||||
|
<p>This is indicated by the feature name: <font face="monospace">action0_roadtype_extra_flags</font>, version 1</p>
|
||||||
|
<br />
|
||||||
<h3><a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Stations">Variational Action 2 - Stations</a></h3>
|
<h3><a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Stations">Variational Action 2 - Stations</a></h3>
|
||||||
<h4>Track type in purchase list (42)</h4>
|
<h4>Track type in purchase list (42)</h4>
|
||||||
<p>This is indicated by the feature name: <font face="monospace">varaction2_station_var42</font>, version 1</p>
|
<p>This is indicated by the feature name: <font face="monospace">varaction2_station_var42</font>, version 1</p>
|
||||||
|
@@ -4568,6 +4568,11 @@ static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, const
|
|||||||
for (int j = buf->ReadByte(); j != 0; j--) buf->ReadDWord();
|
for (int j = buf->ReadByte(); j != 0; j--) buf->ReadDWord();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case A0RPI_ROADTYPE_EXTRA_FLAGS:
|
||||||
|
if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break;
|
||||||
|
rti->extra_flags = (RoadTypeExtraFlags)buf->ReadByte();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = CIR_UNKNOWN;
|
ret = CIR_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
@@ -8381,6 +8386,7 @@ static const GRFFeatureInfo _grf_feature_list[] = {
|
|||||||
GRFFeatureInfo("action5_programmable_signals", 1),
|
GRFFeatureInfo("action5_programmable_signals", 1),
|
||||||
GRFFeatureInfo("action0_railtype_programmable_signals", 1),
|
GRFFeatureInfo("action0_railtype_programmable_signals", 1),
|
||||||
GRFFeatureInfo("action0_railtype_restricted_signals", 1),
|
GRFFeatureInfo("action0_railtype_restricted_signals", 1),
|
||||||
|
GRFFeatureInfo("action0_roadtype_extra_flags", 1),
|
||||||
GRFFeatureInfo(),
|
GRFFeatureInfo(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -8499,6 +8505,8 @@ static const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
|
|||||||
GRFPropertyMapDefinition(GSF_BRIDGES, A0RPI_BRIDGE_AVAILABILITY_FLAGS, "bridge_availability_flags"),
|
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_PROGRAMMABLE_SIGNALS, "railtype_enable_programmable_signals"),
|
||||||
GRFPropertyMapDefinition(GSF_RAILTYPES, A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS, "railtype_enable_restricted_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(),
|
GRFPropertyMapDefinition(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -117,6 +117,7 @@ enum Action0RemapPropertyIds {
|
|||||||
A0RPI_BRIDGE_AVAILABILITY_FLAGS,
|
A0RPI_BRIDGE_AVAILABILITY_FLAGS,
|
||||||
A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS,
|
A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS,
|
||||||
A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS,
|
A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS,
|
||||||
|
A0RPI_ROADTYPE_EXTRA_FLAGS,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GRFPropertyMapFallbackMode {
|
enum GRFPropertyMapFallbackMode {
|
||||||
|
14
src/road.h
14
src/road.h
@@ -51,6 +51,15 @@ enum RoadTypeFlags {
|
|||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(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;
|
struct SpriteGroup;
|
||||||
|
|
||||||
/** Sprite groups for a roadtype. */
|
/** Sprite groups for a roadtype. */
|
||||||
@@ -123,6 +132,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
RoadTypeFlags flags;
|
RoadTypeFlags flags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bit mask of road type extra flags
|
||||||
|
*/
|
||||||
|
RoadTypeExtraFlags extra_flags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cost multiplier for building this road type
|
* Cost multiplier for building this road type
|
||||||
*/
|
*/
|
||||||
|
@@ -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, 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,
|
RoadTypeLabelList(), 0, 0, ROADTYPES_NONE, ROADTYPES_NONE, 0,
|
||||||
{}, {} };
|
{}, {} };
|
||||||
for (; i < lengthof(_roadtypes); i++) _roadtypes[i] = empty_roadtype;
|
for (; i < lengthof(_roadtypes); i++) _roadtypes[i] = empty_roadtype;
|
||||||
@@ -146,6 +146,7 @@ RoadType AllocateRoadType(RoadTypeLabel label, RoadTramType rtt)
|
|||||||
rti->label = label;
|
rti->label = label;
|
||||||
rti->alternate_labels.clear();
|
rti->alternate_labels.clear();
|
||||||
rti->flags = ROTFB_NONE;
|
rti->flags = ROTFB_NONE;
|
||||||
|
rti->extra_flags = RXTFB_NONE;
|
||||||
rti->introduction_date = INVALID_DATE;
|
rti->introduction_date = INVALID_DATE;
|
||||||
|
|
||||||
/* Make us compatible with ourself. */
|
/* Make us compatible with ourself. */
|
||||||
|
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
/* static */ bool ScriptRoad::IsRoadTypeAvailable(RoadType road_type)
|
/* 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()
|
/* static */ ScriptRoad::RoadType ScriptRoad::GetCurrentRoadType()
|
||||||
|
@@ -17,6 +17,9 @@ ScriptRoadTypeList::ScriptRoadTypeList(ScriptRoad::RoadTramTypes rtts)
|
|||||||
{
|
{
|
||||||
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
|
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
|
||||||
if (!HasBit(rtts, GetRoadTramType(rt))) continue;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -861,6 +861,9 @@ class NIHRoadType : public NIHelper {
|
|||||||
HasBit(rti->flags, ROTF_HIDDEN) ? 'h' : '-',
|
HasBit(rti->flags, ROTF_HIDDEN) ? 'h' : '-',
|
||||||
HasBit(rti->flags, ROTF_TOWN_BUILD) ? 'T' : '-');
|
HasBit(rti->flags, ROTF_TOWN_BUILD) ? 'T' : '-');
|
||||||
print(buffer);
|
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);
|
seprintf(buffer, lastof(buffer), " Powered: 0x" OTTD_PRINTFHEX64, rti->powered_roadtypes);
|
||||||
print(buffer);
|
print(buffer);
|
||||||
};
|
};
|
||||||
|
@@ -63,6 +63,9 @@ static const RoadTypeInfo _original_roadtypes[] = {
|
|||||||
/* flags */
|
/* flags */
|
||||||
ROTFB_TOWN_BUILD,
|
ROTFB_TOWN_BUILD,
|
||||||
|
|
||||||
|
/* extra flags */
|
||||||
|
RXTFB_NONE,
|
||||||
|
|
||||||
/* cost multiplier */
|
/* cost multiplier */
|
||||||
8,
|
8,
|
||||||
|
|
||||||
@@ -143,6 +146,9 @@ static const RoadTypeInfo _original_roadtypes[] = {
|
|||||||
/* flags */
|
/* flags */
|
||||||
ROTFB_CATENARY | ROTFB_NO_HOUSES,
|
ROTFB_CATENARY | ROTFB_NO_HOUSES,
|
||||||
|
|
||||||
|
/* extra flags */
|
||||||
|
RXTFB_NONE,
|
||||||
|
|
||||||
/* cost multiplier */
|
/* cost multiplier */
|
||||||
16,
|
16,
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user