Add road stop property to set cost multipliers
This commit is contained in:
@@ -162,6 +162,13 @@
|
||||
Each set of flags is 1 byte, the total property length is 6 bytes.<br />
|
||||
Each set of flags has the format described in the <a href="newgrf-additions.html#bridge_pillar_flags">bridge_pillar_flags property section</a>.
|
||||
</p>
|
||||
<h4 id="roadstop_cost_multipliers">Road stop cost multipliers (15, or mappable property: roadstop_cost_multipliers)</h4>
|
||||
<p>This property sets the build and removal cost multipliers.<br />
|
||||
The first byte is the build cost multiplier.<br />
|
||||
The second byte is the removal cost multiplier.<br />
|
||||
The total property length is 2 bytes.<br />
|
||||
A value of 16 produces a build or removal cost the same as non-NewGRF road stops.</a>.
|
||||
</p>
|
||||
|
||||
<p style="padding-top: 0.25em;">
|
||||
<div id="roadstop_views">The 6 road stop views/rotations are described below.</div>
|
||||
|
@@ -5088,6 +5088,14 @@ static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, const
|
||||
}
|
||||
break;
|
||||
|
||||
case A0RPI_ROADSTOP_COST_MULTIPLIERS:
|
||||
if (MappedPropertyLengthMismatch(buf, 2, mapping_entry)) break;
|
||||
FALLTHROUGH;
|
||||
case 0x15: // Cost multipliers
|
||||
rs->build_cost_multiplier = buf->ReadByte();
|
||||
rs->clear_cost_multiplier = buf->ReadByte();
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = CIR_UNKNOWN;
|
||||
break;
|
||||
|
@@ -103,6 +103,7 @@ extern const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
|
||||
GRFPropertyMapDefinition(GSF_ROADSTOPS, A0RPI_ROADSTOP_GENERAL_FLAGS, "roadstop_general_flags"),
|
||||
GRFPropertyMapDefinition(GSF_ROADSTOPS, A0RPI_ROADSTOP_MIN_BRIDGE_HEIGHT, "roadstop_min_bridge_height"),
|
||||
GRFPropertyMapDefinition(GSF_ROADSTOPS, A0RPI_ROADSTOP_DISALLOWED_BRIDGE_PILLARS, "roadstop_disallowed_bridge_pillars"),
|
||||
GRFPropertyMapDefinition(GSF_ROADSTOPS, A0RPI_ROADSTOP_COST_MULTIPLIERS, "roadstop_cost_multipliers"),
|
||||
GRFPropertyMapDefinition(),
|
||||
};
|
||||
|
||||
|
@@ -52,6 +52,7 @@ enum Action0RemapPropertyIds {
|
||||
A0RPI_ROADSTOP_GENERAL_FLAGS,
|
||||
A0RPI_ROADSTOP_MIN_BRIDGE_HEIGHT,
|
||||
A0RPI_ROADSTOP_DISALLOWED_BRIDGE_PILLARS,
|
||||
A0RPI_ROADSTOP_COST_MULTIPLIERS,
|
||||
};
|
||||
|
||||
|
||||
|
@@ -145,6 +145,21 @@ struct RoadStopSpec {
|
||||
byte bridge_height[6]; ///< Minimum height for a bridge above, 0 for none
|
||||
byte bridge_disallowed_pillars[6]; ///< Disallowed pillar flags for a bridge above
|
||||
|
||||
uint8 build_cost_multiplier = 16; ///< Build cost multiplier per tile.
|
||||
uint8 clear_cost_multiplier = 16; ///< Clear cost multiplier per tile.
|
||||
|
||||
/**
|
||||
* Get the cost for building a road stop of this type.
|
||||
* @return The cost for building.
|
||||
*/
|
||||
Money GetBuildCost(Price category) const { return GetPrice(category, this->build_cost_multiplier, this->grf_prop.grffile, -4); }
|
||||
|
||||
/**
|
||||
* Get the cost for clearing a road stop of this type.
|
||||
* @return The cost for clearing.
|
||||
*/
|
||||
Money GetClearCost(Price category) const { return GetPrice(category, this->clear_cost_multiplier, this->grf_prop.grffile, -4); }
|
||||
|
||||
static const RoadStopSpec *Get(uint16 index);
|
||||
};
|
||||
|
||||
|
@@ -2124,7 +2124,13 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
/* Total road stop cost. */
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION, roadstop_area.w * roadstop_area.h * _price[type ? PR_BUILD_STATION_TRUCK : PR_BUILD_STATION_BUS]);
|
||||
Money unit_cost;
|
||||
if (roadstopspec != nullptr) {
|
||||
unit_cost = roadstopspec->GetBuildCost(type ? PR_BUILD_STATION_TRUCK : PR_BUILD_STATION_BUS);
|
||||
} else {
|
||||
unit_cost = _price[type ? PR_BUILD_STATION_TRUCK : PR_BUILD_STATION_BUS];
|
||||
}
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION, roadstop_area.w * roadstop_area.h * unit_cost);
|
||||
StationID est = INVALID_STATION;
|
||||
ret = CheckFlatLandRoadStop(roadstop_area, roadstopspec, flags, is_drive_through ? 5 << axis : 1 << ddir, is_drive_through, type ? STATION_TRUCK : STATION_BUS, axis, &est, rt, false);
|
||||
if (ret.Failed()) return ret;
|
||||
@@ -2266,6 +2272,8 @@ CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlag flags, int repl
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
const RoadStopSpec *spec = GetRoadStopSpec(tile);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
/* Update company infrastructure counts. */
|
||||
for (RoadTramType rtt : _roadtramtypes) {
|
||||
@@ -2306,7 +2314,7 @@ CommandCost RemoveRoadWaypointStop(TileIndex tile, DoCommandFlag flags, int repl
|
||||
NotifyRoadLayoutChanged(false);
|
||||
}
|
||||
|
||||
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_STATION_TRUCK]);
|
||||
return CommandCost(EXPENSES_CONSTRUCTION, spec != nullptr ? spec->GetClearCost(PR_CLEAR_STATION_TRUCK) : _price[PR_CLEAR_STATION_TRUCK]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2352,6 +2360,8 @@ CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int replacement_
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
const RoadStopSpec *spec = GetRoadStopSpec(tile);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
ZoningMarkDirtyStationCoverageArea(st);
|
||||
if (*primary_stop == cur_stop) {
|
||||
@@ -2419,7 +2429,8 @@ CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int replacement_
|
||||
NotifyRoadLayoutChanged(false);
|
||||
}
|
||||
|
||||
return CommandCost(EXPENSES_CONSTRUCTION, _price[is_truck ? PR_CLEAR_STATION_TRUCK : PR_CLEAR_STATION_BUS]);
|
||||
Price category = is_truck ? PR_CLEAR_STATION_TRUCK : PR_CLEAR_STATION_BUS;
|
||||
return CommandCost(EXPENSES_CONSTRUCTION, spec != nullptr ? spec->GetClearCost(category) : _price[category]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1435,6 +1435,8 @@ class NIHRoadStop : public NIHelper {
|
||||
output.print(buffer);
|
||||
seprintf(buffer, lastof(buffer), " spec: callback mask: %X, flags: %X, intl flags: %X", spec->callback_mask, spec->flags, spec->internal_flags);
|
||||
output.print(buffer);
|
||||
seprintf(buffer, lastof(buffer), " spec: build: %u, clear: %u", spec->build_cost_multiplier, spec->clear_cost_multiplier);
|
||||
output.print(buffer);
|
||||
seprintf(buffer, lastof(buffer), " animation: frames: %u, status: %u, speed: %u, triggers: 0x%X", spec->animation.frames, spec->animation.status, spec->animation.speed, spec->animation.triggers);
|
||||
output.print(buffer);
|
||||
|
||||
|
@@ -378,7 +378,13 @@ CommandCost CmdBuildRoadWaypoint(TileIndex start_tile, DoCommandFlag flags, uint
|
||||
|
||||
TileArea roadstop_area(start_tile, width, height);
|
||||
/* Total road stop cost. */
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION, roadstop_area.w * roadstop_area.h * _price[PR_BUILD_STATION_TRUCK]);
|
||||
Money unit_cost;
|
||||
if (spec != nullptr) {
|
||||
unit_cost = spec->GetBuildCost(PR_BUILD_STATION_TRUCK);
|
||||
} else {
|
||||
unit_cost = _price[PR_BUILD_STATION_TRUCK];
|
||||
}
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION, roadstop_area.w * roadstop_area.h * unit_cost);
|
||||
StationID est = INVALID_STATION;
|
||||
extern CommandCost CheckFlatLandRoadStop(TileArea tile_area, const RoadStopSpec *spec, DoCommandFlag flags, uint invalid_dirs, bool is_drive_through, StationType station_type, Axis axis, StationID *station, RoadType rt, bool require_road);
|
||||
CommandCost ret = CheckFlatLandRoadStop(roadstop_area, spec, flags, 5 << axis, true, STATION_ROADWAYPOINT, axis, &est, INVALID_ROADTYPE, true);
|
||||
|
Reference in New Issue
Block a user