mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-19 21:13:05 +01:00
Move *10 on removal/price to the object load function (#16846)
This simplifies the code and ensures that money32/16 is at the same base for all users of these objects
This commit is contained in:
@@ -1127,7 +1127,7 @@ private:
|
||||
auto* sceneryEntry = get_small_scenery_entry(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price * 10;
|
||||
price = sceneryEntry->price;
|
||||
name = sceneryEntry->name;
|
||||
}
|
||||
break;
|
||||
@@ -1157,7 +1157,7 @@ private:
|
||||
auto* sceneryEntry = get_large_scenery_entry(selectedScenery.EntryIndex);
|
||||
if (sceneryEntry != nullptr)
|
||||
{
|
||||
price = sceneryEntry->price * 10;
|
||||
price = sceneryEntry->price;
|
||||
name = sceneryEntry->name;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -246,7 +246,7 @@ money32 LandSetHeightAction::GetSmallSceneryRemovalCost() const
|
||||
if (sceneryEntry == nullptr)
|
||||
continue;
|
||||
|
||||
cost += MONEY(sceneryEntry->removal_price, 0);
|
||||
cost += sceneryEntry->removal_price;
|
||||
}
|
||||
|
||||
return cost;
|
||||
|
||||
@@ -171,7 +171,7 @@ GameActions::Result LargeSceneryPlaceAction::Query() const
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_RECHECK;
|
||||
|
||||
res.Cost = (sceneryEntry->price * 10) + supportsCost;
|
||||
res.Cost = sceneryEntry->price + supportsCost;
|
||||
res.SetData(std::move(resultData));
|
||||
|
||||
return res;
|
||||
@@ -306,7 +306,7 @@ GameActions::Result LargeSceneryPlaceAction::Execute() const
|
||||
// Force ride construction to recheck area
|
||||
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_RECHECK;
|
||||
|
||||
res.Cost = (sceneryEntry->price * 10) + supportsCost;
|
||||
res.Cost = sceneryEntry->price + supportsCost;
|
||||
res.SetData(std::move(resultData));
|
||||
|
||||
return res;
|
||||
|
||||
@@ -116,7 +116,7 @@ GameActions::Result LargeSceneryRemoveAction::Query() const
|
||||
}
|
||||
|
||||
if (calculate_cost)
|
||||
res.Cost = sceneryEntry->removal_price * 10;
|
||||
res.Cost = sceneryEntry->removal_price;
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ GameActions::Result LargeSceneryRemoveAction::Execute() const
|
||||
}
|
||||
}
|
||||
|
||||
res.Cost = sceneryEntry->removal_price * 10;
|
||||
res.Cost = sceneryEntry->removal_price;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ GameActions::Result SmallSceneryPlaceAction::Query() const
|
||||
res.SetData(SmallSceneryPlaceActionResult{ groundFlags, 0, 0 });
|
||||
|
||||
res.Expenditure = ExpenditureType::Landscaping;
|
||||
res.Cost = (sceneryEntry->price * 10) + canBuild.Cost;
|
||||
res.Cost = sceneryEntry->price + canBuild.Cost;
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -405,7 +405,7 @@ GameActions::Result SmallSceneryPlaceAction::Execute() const
|
||||
}
|
||||
|
||||
res.Expenditure = ExpenditureType::Landscaping;
|
||||
res.Cost = (sceneryEntry->price * 10) + canBuild.Cost;
|
||||
res.Cost = sceneryEntry->price + canBuild.Cost;
|
||||
|
||||
auto* sceneryElement = TileElementInsert<SmallSceneryElement>(
|
||||
CoordsXYZ{ _loc, zLow }, quarterTile.GetBaseQuarterOccupied());
|
||||
|
||||
@@ -68,7 +68,7 @@ GameActions::Result SmallSceneryRemoveAction::Query() const
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
|
||||
}
|
||||
|
||||
res.Cost = entry->removal_price * 10;
|
||||
res.Cost = entry->removal_price;
|
||||
res.Expenditure = ExpenditureType::Landscaping;
|
||||
res.Position = _loc;
|
||||
|
||||
@@ -117,7 +117,7 @@ GameActions::Result SmallSceneryRemoveAction::Execute() const
|
||||
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
|
||||
}
|
||||
|
||||
res.Cost = entry->removal_price * 10;
|
||||
res.Cost = entry->removal_price;
|
||||
res.Expenditure = ExpenditureType::Landscaping;
|
||||
res.Position = _loc;
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ void LargeSceneryObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStre
|
||||
stream->Seek(6, OpenRCT2::STREAM_SEEK_CURRENT);
|
||||
_legacyType.tool_id = static_cast<CursorID>(stream->ReadValue<uint8_t>());
|
||||
_legacyType.flags = stream->ReadValue<uint8_t>();
|
||||
_legacyType.price = stream->ReadValue<int16_t>();
|
||||
_legacyType.removal_price = stream->ReadValue<int16_t>();
|
||||
_legacyType.price = stream->ReadValue<int16_t>() * 10;
|
||||
_legacyType.removal_price = stream->ReadValue<int16_t>() * 10;
|
||||
stream->Seek(5, OpenRCT2::STREAM_SEEK_CURRENT);
|
||||
_legacyType.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL;
|
||||
_legacyType.scrolling_mode = stream->ReadValue<uint8_t>();
|
||||
@@ -61,7 +61,7 @@ void LargeSceneryObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStre
|
||||
if (_legacyType.removal_price <= 0)
|
||||
{
|
||||
// Make sure you don't make a profit when placing then removing.
|
||||
money16 reimbursement = _legacyType.removal_price;
|
||||
const auto reimbursement = _legacyType.removal_price;
|
||||
if (reimbursement > _legacyType.price)
|
||||
{
|
||||
context->LogError(ObjectError::InvalidProperty, "Sell price can not be more than buy price.");
|
||||
@@ -140,8 +140,8 @@ void LargeSceneryObject::ReadJson(IReadObjectContext* context, json_t& root)
|
||||
{
|
||||
_legacyType.tool_id = Cursor::FromString(Json::GetString(properties["cursor"]), CursorID::StatueDown);
|
||||
|
||||
_legacyType.price = Json::GetNumber<int16_t>(properties["price"]);
|
||||
_legacyType.removal_price = Json::GetNumber<int16_t>(properties["removalPrice"]);
|
||||
_legacyType.price = Json::GetNumber<int16_t>(properties["price"]) * 10;
|
||||
_legacyType.removal_price = Json::GetNumber<int16_t>(properties["removalPrice"]) * 10;
|
||||
|
||||
_legacyType.scrolling_mode = Json::GetNumber<uint8_t>(properties["scrollingMode"], SCROLLING_MODE_NONE);
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ void SmallSceneryObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStre
|
||||
_legacyType.flags = stream->ReadValue<uint32_t>();
|
||||
_legacyType.height = stream->ReadValue<uint8_t>();
|
||||
_legacyType.tool_id = static_cast<CursorID>(stream->ReadValue<uint8_t>());
|
||||
_legacyType.price = stream->ReadValue<int16_t>();
|
||||
_legacyType.removal_price = stream->ReadValue<int16_t>();
|
||||
_legacyType.price = stream->ReadValue<int16_t>() * 10;
|
||||
_legacyType.removal_price = stream->ReadValue<int16_t>() * 10;
|
||||
stream->Seek(4, OpenRCT2::STREAM_SEEK_CURRENT);
|
||||
_legacyType.animation_delay = stream->ReadValue<uint16_t>();
|
||||
_legacyType.animation_mask = stream->ReadValue<uint16_t>();
|
||||
@@ -63,7 +63,7 @@ void SmallSceneryObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStre
|
||||
if (_legacyType.removal_price <= 0)
|
||||
{
|
||||
// Make sure you don't make a profit when placing then removing.
|
||||
money16 reimbursement = _legacyType.removal_price;
|
||||
const auto reimbursement = _legacyType.removal_price;
|
||||
if (reimbursement > _legacyType.price)
|
||||
{
|
||||
context->LogError(ObjectError::InvalidProperty, "Sell price can not be more than buy price.");
|
||||
@@ -231,8 +231,8 @@ void SmallSceneryObject::ReadJson(IReadObjectContext* context, json_t& root)
|
||||
{
|
||||
_legacyType.height = Json::GetNumber<uint8_t>(properties["height"]);
|
||||
_legacyType.tool_id = Cursor::FromString(Json::GetString(properties["cursor"]), CursorID::StatueDown);
|
||||
_legacyType.price = Json::GetNumber<uint16_t>(properties["price"]);
|
||||
_legacyType.removal_price = Json::GetNumber<uint16_t>(properties["removalPrice"]);
|
||||
_legacyType.price = Json::GetNumber<uint16_t>(properties["price"]) * 10;
|
||||
_legacyType.removal_price = Json::GetNumber<uint16_t>(properties["removalPrice"]) * 10;
|
||||
_legacyType.animation_delay = Json::GetNumber<uint16_t>(properties["animationDelay"]);
|
||||
_legacyType.animation_mask = Json::GetNumber<uint16_t>(properties["animationMask"]);
|
||||
_legacyType.num_frames = Json::GetNumber<uint16_t>(properties["numFrames"]);
|
||||
|
||||
@@ -37,7 +37,7 @@ static int32_t map_place_clear_func(
|
||||
}
|
||||
|
||||
if (!(gParkFlags & PARK_FLAGS_NO_MONEY) && scenery != nullptr)
|
||||
*price += scenery->removal_price * 10;
|
||||
*price += scenery->removal_price;
|
||||
|
||||
if (flags & GAME_COMMAND_FLAG_GHOST)
|
||||
return 0;
|
||||
|
||||
@@ -80,8 +80,8 @@ struct LargeSceneryEntry : SceneryEntryBase
|
||||
{
|
||||
CursorID tool_id;
|
||||
uint8_t flags;
|
||||
int16_t price;
|
||||
int16_t removal_price;
|
||||
money32 price;
|
||||
money32 removal_price;
|
||||
rct_large_scenery_tile* tiles;
|
||||
ObjectEntryIndex scenery_tab_id;
|
||||
uint8_t scrolling_mode;
|
||||
@@ -126,8 +126,8 @@ struct SmallSceneryEntry : SceneryEntryBase
|
||||
uint32_t flags;
|
||||
uint8_t height;
|
||||
CursorID tool_id;
|
||||
int16_t price;
|
||||
int16_t removal_price;
|
||||
money32 price;
|
||||
money32 removal_price;
|
||||
uint8_t* frame_offsets;
|
||||
uint16_t animation_delay;
|
||||
uint16_t animation_mask;
|
||||
@@ -146,7 +146,7 @@ struct WallSceneryEntry : SceneryEntryBase
|
||||
uint8_t flags;
|
||||
uint8_t height;
|
||||
uint8_t flags2;
|
||||
int16_t price;
|
||||
money16 price;
|
||||
ObjectEntryIndex scenery_tab_id;
|
||||
uint8_t scrolling_mode;
|
||||
};
|
||||
@@ -157,7 +157,7 @@ struct PathBitEntry : SceneryEntryBase
|
||||
uint16_t flags;
|
||||
PathBitDrawType draw_type;
|
||||
CursorID tool_id;
|
||||
int16_t price;
|
||||
money16 price;
|
||||
ObjectEntryIndex scenery_tab_id;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user