1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

add object property validation

This commit is contained in:
Ted John
2016-07-02 17:23:06 +01:00
parent 7e1f948e19
commit 2cade7dd13
7 changed files with 68 additions and 0 deletions

View File

@@ -44,6 +44,12 @@ void BannerObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
_sceneryTabEntry = stream->ReadValue<rct_object_entry>();
GetImageTable()->Read(context, stream);
// Validate properties
if (_legacyType.large_scenery.price <= 0)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Price can not be free or negative.");
}
}
void BannerObject::Load()

View File

@@ -43,6 +43,12 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext * context, IStream * stre
_sceneryTabEntry = stream->ReadValue<rct_object_entry>();
GetImageTable()->Read(context, stream);
// Validate properties
if (_legacyType.large_scenery.price <= 0)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Price can not be free or negative.");
}
}
void FootpathItemObject::Load()

View File

@@ -41,6 +41,12 @@ void FootpathObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
GetStringTable()->Read(context, stream, OBJ_STRING_ID_NAME);
GetImageTable()->Read(context, stream);
// Validate properties
if (_legacyType.var_0A > 1)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "VAR_0A can not be greater than 1.");
}
}
void FootpathObject::Load()

View File

@@ -63,6 +63,21 @@ void LargeSceneryObject::ReadLegacy(IReadObjectContext * context, IStream * stre
_tiles = ReadTiles(stream);
GetImageTable()->Read(context, stream);
// Validate properties
if (_legacyType.large_scenery.price <= 0)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Price can not be free or negative.");
}
if (_legacyType.large_scenery.removal_price <= 0)
{
// Make sure you don't make a profit when placing then removing.
money16 reimbursement = _legacyType.large_scenery.removal_price;
if (reimbursement > _legacyType.large_scenery.price)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Sell price can not be more than buy price.");
}
}
}
void LargeSceneryObject::Load()

View File

@@ -80,6 +80,20 @@ void RideObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
}
GetImageTable()->Read(context, stream);
// Validate properties
if (_legacyType.excitement_multipler > 75)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Excitement multiplier too high.");
}
if (_legacyType.intensity_multipler > 75)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Intensity multiplier too high.");
}
if (_legacyType.nausea_multipler > 75)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Nausea multiplier too high.");
}
}
void RideObject::Load()

View File

@@ -61,6 +61,21 @@ void SmallSceneryObject::ReadLegacy(IReadObjectContext * context, IStream * stre
}
GetImageTable()->Read(context, stream);
// Validate properties
if (_legacyType.small_scenery.price <= 0)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Price can not be free or negative.");
}
if (_legacyType.small_scenery.removal_price <= 0)
{
// Make sure you don't make a profit when placing then removing.
money16 reimbursement = _legacyType.small_scenery.removal_price;
if (reimbursement > _legacyType.small_scenery.price)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Sell price can not be more than buy price.");
}
}
}
void SmallSceneryObject::Load()

View File

@@ -47,6 +47,12 @@ void WallObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
_sceneryTabEntry = stream->ReadValue<rct_object_entry>();
GetImageTable()->Read(context, stream);
// Validate properties
if (_legacyType.large_scenery.price <= 0)
{
context->LogError(OBJECT_ERROR_INVALID_PROPERTY, "Price can not be free or negative.");
}
}
void WallObject::Load()