forked from rosebudai/OpenRCT2-Web
Fix negative marketing campaign durations (#26789)
* fix: reject non-positive marketing durations * Bump network version --------- Co-authored-by: Tulio Leao <tupscal@pm.me>
This commit is contained in:
1 parent
8e64399c50
commit
02c42246fe
2 files changed
+13
-1
No files matched your search
@@ -47,7 +47,7 @@ namespace OpenRCT2::GameActions
|
||||
|
||||
Result ParkMarketingAction::Query(GameState_t& gameState, Park::ParkData& park) const
|
||||
{
|
||||
if (static_cast<size_t>(_type) >= std::size(AdvertisingCampaignPricePerWeek) || _numWeeks >= 256)
|
||||
if (static_cast<size_t>(_type) >= std::size(AdvertisingCampaignPricePerWeek) || _numWeeks <= 0 || _numWeeks >= 256)
|
||||
{
|
||||
return Result(Status::invalidParameters, STR_CANT_START_MARKETING_CAMPAIGN, STR_ERR_VALUE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/ParkImporter.h>
|
||||
#include <openrct2/actions/GameActionRunner.h>
|
||||
#include <openrct2/actions/park/ParkMarketingAction.h>
|
||||
#include <openrct2/actions/park/ParkSetEntranceFeeAction.h>
|
||||
#include <openrct2/actions/park/ParkSetParameterAction.h>
|
||||
#include <openrct2/actions/ride/RideSetPriceAction.h>
|
||||
@@ -86,6 +87,17 @@ static void execute(Args&&... args)
|
||||
GameActions::Execute(&ga, getGameState());
|
||||
}
|
||||
|
||||
TEST_F(PlayTests, NegativeMarketingCampaignDurationIsRejected)
|
||||
{
|
||||
auto context = localStartGame(TestData::GetParkPath("small_park_with_ferris_wheel.sv6"));
|
||||
ASSERT_NE(context.get(), nullptr);
|
||||
|
||||
GameActions::ParkMarketingAction action(ADVERTISING_CAMPAIGN_PARK, 0, -1);
|
||||
const auto result = GameActions::Query(&action, getGameState());
|
||||
|
||||
ASSERT_EQ(result.error, GameActions::Status::invalidParameters);
|
||||
}
|
||||
|
||||
TEST_F(PlayTests, SecondGuestInQueueShouldNotRideIfNoFunds)
|
||||
{
|
||||
/* This test verifies that a guest, when second in queue, won't be forced to enter
|
||||
|
||||
Reference in new issue
Block a user