Implement road removal game command#3052
Conversation
2653c49 to
a29234b
Compare
a29234b to
50e1f0d
Compare
| /* | ||
| // This part was made redundant by a no-op write in Hooks.cpp: | ||
| // writeNop(0x004776DD, 6); | ||
| // TODO: turn this into a setting? | ||
| if (companyId != CompanyId::neutral && roadEl->hasUnk7_40() || roadEl->hasUnk7_80()) | ||
| { | ||
| setErrorText(StringIds::empty); | ||
|
|
||
| auto nearest = TownManager::getClosestTownAndDensity(args.pos); | ||
| if (nearest.has_value()) | ||
| { | ||
| auto* town = TownManager::get(nearest->first); | ||
| FormatArguments::common(town->name); | ||
| setErrorText(StringIds::stringid_local_authority_wont_allow_removal_in_use); | ||
| return FAILURE; | ||
| } | ||
| } | ||
| */ |
There was a problem hiding this comment.
I think we should probably turn this into a proper setting, rather than omitting it outright? Then again, it's been like this since 2018... @duncanspumpkin, any thoughts?
There was a problem hiding this comment.
yes should probably make it a setting but can look at it later.
| // This part was made redundant by a no-op write in Hooks.cpp: | ||
| // writeNop(0x004776DD, 6); | ||
| // TODO: turn this into a setting? | ||
| if (companyId != CompanyId::neutral && roadEl->hasUnk7_40() || roadEl->hasUnk7_80()) |
There was a problem hiding this comment.
I mentioned this on Discord, but for posterity: I think this is right for tram tracks, but the wrong check to use for other road types. For regular roads, unk4u (two bits) should probably be read instead? Consider:
OpenLoco/src/OpenLoco/src/Vehicles/Vehicle.cpp
Lines 555 to 563 in d505688
| auto tile = World::TileManager::get(args.pos.x, args.pos.y); | ||
|
|
||
| if (auto* roadEl = getRoadElement(tile, args, args.sequenceIndex, flags); roadEl != nullptr) | ||
| { |
There was a problem hiding this comment.
if roadElement is nullptr we should safely handle that and return FAILURE (this would be a change from vanilla)
f4283da to
a1cadbe
Compare
Not sure where I even got the idea for this check from??
8fe0feb to
00032b6
Compare
| // Seems to have been forgotten in vanilla | ||
| if (removeRoadBridge) | ||
| { | ||
| const auto* bridgeObj = ObjectManager::get<BridgeObject>(roadBridgeId); | ||
| const auto bridgeBaseCost = Economy::getInflationAdjustedCost(bridgeObj->sellCostFactor, bridgeObj->costIndex, 10); | ||
| totalRemovalCost += (bridgeBaseCost * World::TrackData::getRoadMiscData(args.roadId).costFactor) / 256; | ||
| } |
There was a problem hiding this comment.
Vanilla change/fix that was omitted from the changelog?
Also #3268
To do: