Add `LOG_ERROR` calls

This commit is contained in:
Peter Froud 2024-03-17 00:19:56 -07:00 committed by Gymnasiast
parent d1f740c786
commit 1f698dfc76
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
19 changed files with 64 additions and 11 deletions

View File

@ -72,6 +72,7 @@ GameActions::Result CheatSetAction::Query() const
{
if (static_cast<uint32_t>(_cheatType) >= static_cast<uint32_t>(CheatType::Count))
{
LOG_ERROR("Invalid cheat type %u", _cheatType);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}
@ -80,11 +81,17 @@ GameActions::Result CheatSetAction::Query() const
if (_param1 < validRange.first.first || _param1 > validRange.first.second)
{
LOG_ERROR(
"The first cheat parameter is out of range. Value = %d, min = %d, max = %d", _param1, validRange.first.first,
validRange.first.second);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}
if (_param2 < validRange.second.first || _param2 > validRange.second.second)
{
LOG_ERROR(
"The second cheat parameter is out of range. Value = %d, min = %d, max = %d", _param2, validRange.second.first,
validRange.second.second);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}

View File

@ -37,6 +37,7 @@ GameActions::Result ClimateSetAction::Query() const
{
if (_climate >= ClimateType::Count)
{
LOG_ERROR("Invalid climate type %u", _climate);
return GameActions::Result(GameActions::Status::InvalidParameters, STR_INVALID_CLIMATE_ID, STR_NONE);
}

View File

@ -99,6 +99,7 @@ GameActions::Result FootpathAdditionPlaceAction::Query() const
auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry<PathAdditionEntry>(_entryIndex);
if (pathAdditionEntry == nullptr)
{
LOG_ERROR("Unknown footpath addition entry for entryIndex %d", _entryIndex);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
}
@ -167,6 +168,7 @@ GameActions::Result FootpathAdditionPlaceAction::Execute() const
auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry<PathAdditionEntry>(_entryIndex);
if (pathAdditionEntry == nullptr)
{
LOG_ERROR("Unknown footpath addition entry for entryIndex %d", _entryIndex);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
}

View File

@ -110,7 +110,7 @@ GameActions::Result LargeScenerySetColourAction::QueryExecute(bool isExecuting)
if (sceneryEntry == nullptr)
{
LOG_ERROR("Could not find scenery object. type = %u", largeElement->GetEntryIndex());
LOG_ERROR("Scenery element doesn't have scenery entry");
return GameActions::Result(GameActions::Status::Unknown, STR_CANT_REPAINT_THIS, STR_NONE);
}
// Work out the base tile coordinates (Tile with index 0)

View File

@ -122,8 +122,9 @@ GameActions::Result MazePlaceTrackAction::Query() const
auto ride = GetRide(_rideIndex);
if (ride == nullptr || ride->type == RIDE_TYPE_NULL)
{
LOG_ERROR("Ride not found for rideIndex %u", _rideIndex);
res.Error = GameActions::Status::InvalidParameters;
res.ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS;
res.ErrorMessage = STR_ERR_RIDE_NOT_FOUND;
return res;
}
@ -143,8 +144,9 @@ GameActions::Result MazePlaceTrackAction::Execute() const
auto ride = GetRide(_rideIndex);
if (ride == nullptr)
{
LOG_ERROR("Ride not found for rideIndex %u", _rideIndex);
res.Error = GameActions::Status::InvalidParameters;
res.ErrorMessage = STR_NONE;
res.ErrorMessage = STR_ERR_RIDE_NOT_FOUND;
return res;
}

View File

@ -168,8 +168,9 @@ GameActions::Result MazeSetTrackAction::Query() const
auto ride = GetRide(_rideIndex);
if (ride == nullptr || ride->type == RIDE_CRASH_TYPE_NONE)
{
LOG_ERROR("Ride not found for rideIndex %u", _rideIndex);
res.Error = GameActions::Status::NoClearance;
res.ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS;
res.ErrorMessage = STR_ERR_RIDE_NOT_FOUND;
return res;
}
@ -192,8 +193,9 @@ GameActions::Result MazeSetTrackAction::Execute() const
auto ride = GetRide(_rideIndex);
if (ride == nullptr)
{
LOG_ERROR("Ride not found for rideIndex %u", _rideIndex);
res.Error = GameActions::Status::InvalidParameters;
res.ErrorMessage = STR_NONE;
res.ErrorMessage = STR_ERR_RIDE_NOT_FOUND;
return res;
}

View File

@ -45,8 +45,21 @@ void ParkSetDateAction::Serialise(DataSerialiser& stream)
GameActions::Result ParkSetDateAction::Query() const
{
if (_year < 0 || _year >= kMaxYear || _month < 0 || _month >= MONTH_COUNT || _day < 0 || _day >= 31)
if (_year < 0 || _year >= kMaxYear)
{
LOG_ERROR("Invalid park date year %d", _year);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}
if (_month < 0 || _month >= MONTH_COUNT)
{
LOG_ERROR("Invalid park date month %d", _year);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}
if (_day < 0 || _day >= 31)
{
LOG_ERROR("Invalid park date day %d", _year);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}

View File

@ -42,17 +42,25 @@ void ParkSetEntranceFeeAction::Serialise(DataSerialiser& stream)
GameActions::Result ParkSetEntranceFeeAction::Query() const
{
bool noMoney = (GetGameState().ParkFlags & PARK_FLAGS_NO_MONEY) != 0;
bool forceFreeEntry = !ParkEntranceFeeUnlocked();
if (noMoney || forceFreeEntry)
if ((GetGameState().ParkFlags & PARK_FLAGS_NO_MONEY) != 0)
{
LOG_ERROR("Can't set park entrance fee because the park has no money");
return GameActions::Result(GameActions::Status::Disallowed, STR_ERR_CANT_CHANGE_PARK_ENTRANCE_FEE, STR_NONE);
}
if (!ParkEntranceFeeUnlocked())
{
LOG_ERROR("Park entrance fee is locked");
return GameActions::Result(GameActions::Status::Disallowed, STR_ERR_CANT_CHANGE_PARK_ENTRANCE_FEE, STR_NONE);
}
if (_fee < 0.00_GBP || _fee > MAX_ENTRANCE_FEE)
{
LOG_ERROR("Invalid park entrance fee %d", _fee);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}
return GameActions::Result();
}

View File

@ -47,6 +47,7 @@ GameActions::Result ParkSetNameAction::Query() const
{
if (_name.empty())
{
LOG_ERROR("Can't set park name to empty string");
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_RENAME_PARK, STR_INVALID_NAME_FOR_PARK);
}
return GameActions::Result();

View File

@ -44,6 +44,7 @@ GameActions::Result ParkSetParameterAction::Query() const
{
if (_parameter >= ParkParameter::Count)
{
LOG_ERROR("Invalid park parameter %d", _parameter);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}
@ -77,6 +78,7 @@ GameActions::Result ParkSetParameterAction::Execute() const
WindowInvalidateByClass(WindowClass::Ride);
break;
default:
LOG_ERROR("Invalid park parameter %d", _parameter);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}

View File

@ -47,6 +47,7 @@ GameActions::Result ParkSetResearchFundingAction::Query() const
{
if (_fundingAmount >= RESEARCH_FUNDING_COUNT)
{
LOG_ERROR("Invalid research funding amount %d", _fundingAmount);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}

View File

@ -83,6 +83,7 @@ GameActions::Result RideCreateAction::Query() const
if (_rideType >= RIDE_TYPE_COUNT)
{
LOG_ERROR("Invalid ride type %d", _rideType);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_INVALID_RIDE_TYPE);
}
@ -90,6 +91,7 @@ GameActions::Result RideCreateAction::Query() const
int32_t rideEntryIndex = RideGetEntryIndex(_rideType, _subType);
if (rideEntryIndex >= MAX_RIDE_OBJECTS)
{
LOG_ERROR("Ride entry not found for rideType %d, subType %d", _rideType, _subType);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_INVALID_RIDE_TYPE);
}
@ -97,12 +99,14 @@ GameActions::Result RideCreateAction::Query() const
const auto& colourPresets = GetRideTypeDescriptor(_rideType).ColourPresets;
if (_colour1 >= colourPresets.count)
{
LOG_ERROR("Can't create ride, invalid colour preset %d", _colour1);
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_NONE);
}
const auto* rideEntry = GetRideEntryByIndex(rideEntryIndex);
if (rideEntry == nullptr)
{
LOG_ERROR("Ride entry not found for rideEntryIndex %d", rideEntryIndex);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_UNKNOWN_OBJECT_TYPE);
}

View File

@ -115,9 +115,10 @@ GameActions::Result RideDemolishAction::Execute() const
return DemolishRide(*ride);
case RIDE_MODIFY_RENEW:
return RefurbishRide(*ride);
default:
LOG_ERROR("Unknown ride demolish type %d", _modifyType);
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_DO_THIS, STR_NONE);
}
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_DO_THIS, STR_NONE);
}
GameActions::Result RideDemolishAction::DemolishRide(Ride& ride) const

View File

@ -121,6 +121,7 @@ GameActions::Result SmallSceneryPlaceAction::Query() const
auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(_sceneryType);
if (sceneryEntry == nullptr)
{
LOG_ERROR("Small scenery object entry not found for sceneryType %u", _sceneryType);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
}
@ -316,6 +317,7 @@ GameActions::Result SmallSceneryPlaceAction::Execute() const
auto* sceneryEntry = ObjectManager::GetObjectEntry<SmallSceneryEntry>(_sceneryType);
if (sceneryEntry == nullptr)
{
LOG_ERROR("Small scenery object entry not found for sceneryType %u", _sceneryType);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
}

View File

@ -66,6 +66,7 @@ GameActions::Result SmallSceneryRemoveAction::Query() const
auto* entry = OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(_sceneryType);
if (entry == nullptr)
{
LOG_ERROR("Invalid small scenery type %u", _sceneryType);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
}
@ -102,6 +103,7 @@ GameActions::Result SmallSceneryRemoveAction::Query() const
TileElement* tileElement = FindSceneryElement();
if (tileElement == nullptr)
{
LOG_ERROR("Small scenery of type %u not found at x = %d, y = %d, z = &d", _sceneryType, _loc.x, _loc.y, _loc.z);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
}
@ -116,6 +118,7 @@ GameActions::Result SmallSceneryRemoveAction::Execute() const
auto* entry = OpenRCT2::ObjectManager::GetObjectEntry<SmallSceneryEntry>(_sceneryType);
if (entry == nullptr)
{
LOG_ERROR("Invalid small scenery type %u", _sceneryType);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS);
}

View File

@ -47,6 +47,7 @@ GameActions::Result StaffSetColourAction::Query() const
auto staffType = static_cast<StaffType>(_staffType);
if (staffType != StaffType::Handyman && staffType != StaffType::Mechanic && staffType != StaffType::Security)
{
LOG_ERROR("Staff color can't be changed for staff type %d", _staffType);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_ACTION_INVALID_FOR_THAT_STAFF_TYPE);
}

View File

@ -64,6 +64,7 @@ GameActions::Result StaffSetCostumeAction::Query() const
{
if (_spriteIndex.ToUnderlying() >= MAX_ENTITIES || _spriteIndex.IsNull())
{
LOG_ERROR("Invalid sprite index %u", _spriteIndex);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}

View File

@ -49,6 +49,7 @@ GameActions::Result StaffSetNameAction::Query() const
{
if (_spriteIndex.ToUnderlying() >= MAX_ENTITIES || _spriteIndex.IsNull())
{
LOG_ERROR("Invalid sprite index %u", _spriteIndex);
return GameActions::Result(GameActions::Status::InvalidParameters, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE);
}

View File

@ -45,6 +45,7 @@ GameActions::Result StaffSetOrdersAction::Query() const
{
if (_spriteIndex.ToUnderlying() >= MAX_ENTITIES || _spriteIndex.IsNull())
{
LOG_ERROR("Invalid sprite index %u", _spriteIndex);
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE);
}