1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Clean up voucher arguments

This commit is contained in:
Gymnasiast
2020-06-08 14:23:33 +02:00
parent db764445ed
commit e8d6383f57
13 changed files with 25 additions and 17 deletions

View File

@@ -1988,7 +1988,7 @@ static rct_string_id window_guest_inventory_format_item(Peep* peep, int32_t item
ft.Add<const char*>(parkName); ft.Add<const char*>(parkName);
break; break;
case VOUCHER_TYPE_RIDE_FREE: case VOUCHER_TYPE_RIDE_FREE:
ride = get_ride(peep->VoucherArguments); ride = get_ride(peep->VoucherRideId);
if (ride != nullptr) if (ride != nullptr)
{ {
ft.Rewind(); ft.Rewind();
@@ -2008,7 +2008,7 @@ static rct_string_id window_guest_inventory_format_item(Peep* peep, int32_t item
ft.Rewind(); ft.Rewind();
ft.Increment(6); ft.Increment(6);
ft.Add<rct_string_id>(STR_PEEP_INVENTORY_VOUCHER_FOOD_OR_DRINK_FREE); ft.Add<rct_string_id>(STR_PEEP_INVENTORY_VOUCHER_FOOD_OR_DRINK_FREE);
ft.Add<rct_string_id>(ShopItems[peep->VoucherArguments].Naming.Singular); ft.Add<rct_string_id>(ShopItems[peep->VoucherShopItem].Naming.Singular);
break; break;
} }
break; break;

View File

@@ -304,7 +304,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots
COMPARE_FIELD(Peep, AmountOfSouvenirs); COMPARE_FIELD(Peep, AmountOfSouvenirs);
COMPARE_FIELD(Peep, VandalismSeen); COMPARE_FIELD(Peep, VandalismSeen);
COMPARE_FIELD(Peep, VoucherType); COMPARE_FIELD(Peep, VoucherType);
COMPARE_FIELD(Peep, VoucherArguments); COMPARE_FIELD(Peep, VoucherRideId);
COMPARE_FIELD(Peep, SurroundingsThoughtTimeout); COMPARE_FIELD(Peep, SurroundingsThoughtTimeout);
COMPARE_FIELD(Peep, Angriness); COMPARE_FIELD(Peep, Angriness);
COMPARE_FIELD(Peep, TimeLost); COMPARE_FIELD(Peep, TimeLost);

View File

@@ -176,7 +176,7 @@ private:
// remove any free voucher for this ride from peep // remove any free voucher for this ride from peep
if (peep->ItemStandardFlags & PEEP_ITEM_VOUCHER) if (peep->ItemStandardFlags & PEEP_ITEM_VOUCHER)
{ {
if (peep->VoucherType == VOUCHER_TYPE_RIDE_FREE && peep->VoucherArguments == _rideIndex) if (peep->VoucherType == VOUCHER_TYPE_RIDE_FREE && peep->VoucherRideId == _rideIndex)
{ {
peep->ItemStandardFlags &= ~(PEEP_ITEM_VOUCHER); peep->ItemStandardFlags &= ~(PEEP_ITEM_VOUCHER);
} }

View File

@@ -141,7 +141,7 @@ void marketing_set_guest_campaign(Peep* peep, int32_t campaignType)
case ADVERTISING_CAMPAIGN_RIDE_FREE: case ADVERTISING_CAMPAIGN_RIDE_FREE:
peep->ItemStandardFlags |= PEEP_ITEM_VOUCHER; peep->ItemStandardFlags |= PEEP_ITEM_VOUCHER;
peep->VoucherType = VOUCHER_TYPE_RIDE_FREE; peep->VoucherType = VOUCHER_TYPE_RIDE_FREE;
peep->VoucherArguments = campaign->RideId; peep->VoucherRideId = campaign->RideId;
peep->GuestHeadingToRideId = campaign->RideId; peep->GuestHeadingToRideId = campaign->RideId;
peep->GuestIsLostCountdown = 240; peep->GuestIsLostCountdown = 240;
break; break;
@@ -152,7 +152,7 @@ void marketing_set_guest_campaign(Peep* peep, int32_t campaignType)
case ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE: case ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE:
peep->ItemStandardFlags |= PEEP_ITEM_VOUCHER; peep->ItemStandardFlags |= PEEP_ITEM_VOUCHER;
peep->VoucherType = VOUCHER_TYPE_FOOD_OR_DRINK_FREE; peep->VoucherType = VOUCHER_TYPE_FOOD_OR_DRINK_FREE;
peep->VoucherArguments = campaign->ShopItemType; peep->VoucherShopItem = campaign->ShopItemType;
break; break;
case ADVERTISING_CAMPAIGN_PARK: case ADVERTISING_CAMPAIGN_PARK:
break; break;

View File

@@ -12,6 +12,7 @@
#include "../Cheats.h" #include "../Cheats.h"
#include "../common.h" #include "../common.h"
#include "../peep/Peep.h" #include "../peep/Peep.h"
#include "../ride/ShopItem.h"
#include <vector> #include <vector>
@@ -48,7 +49,7 @@ struct MarketingCampaign
union union
{ {
ride_id_t RideId{}; ride_id_t RideId{};
uint8_t ShopItemType; ShopItemIndex ShopItemType;
}; };
}; };

View File

@@ -1483,7 +1483,7 @@ bool Guest::DecideAndBuyItem(Ride* ride, int32_t shopItem, money32 price)
bool hasVoucher = false; bool hasVoucher = false;
if ((ItemStandardFlags & PEEP_ITEM_VOUCHER) && (VoucherType == VOUCHER_TYPE_FOOD_OR_DRINK_FREE) if ((ItemStandardFlags & PEEP_ITEM_VOUCHER) && (VoucherType == VOUCHER_TYPE_FOOD_OR_DRINK_FREE)
&& (VoucherArguments == shopItem)) && (VoucherShopItem == shopItem))
{ {
hasVoucher = true; hasVoucher = true;
} }
@@ -2415,7 +2415,7 @@ void Guest::ReadMap()
static bool peep_has_voucher_for_free_ride(Peep* peep, Ride* ride) static bool peep_has_voucher_for_free_ride(Peep* peep, Ride* ride)
{ {
return peep->ItemStandardFlags & PEEP_ITEM_VOUCHER && peep->VoucherType == VOUCHER_TYPE_RIDE_FREE return peep->ItemStandardFlags & PEEP_ITEM_VOUCHER && peep->VoucherType == VOUCHER_TYPE_RIDE_FREE
&& peep->VoucherArguments == ride->id; && peep->VoucherRideId == ride->id;
} }
/** /**
@@ -2636,7 +2636,7 @@ static void peep_update_ride_at_entrance_try_leave(Guest* peep)
static bool peep_check_ride_price_at_entrance(Guest* peep, Ride* ride, money32 ridePrice) static bool peep_check_ride_price_at_entrance(Guest* peep, Ride* ride, money32 ridePrice)
{ {
if ((peep->ItemStandardFlags & PEEP_ITEM_VOUCHER) && peep->VoucherType == VOUCHER_TYPE_RIDE_FREE if ((peep->ItemStandardFlags & PEEP_ITEM_VOUCHER) && peep->VoucherType == VOUCHER_TYPE_RIDE_FREE
&& peep->VoucherArguments == peep->CurrentRide) && peep->VoucherRideId == peep->CurrentRide)
return true; return true;
if (peep->CashInPocket <= 0 && !(gParkFlags & PARK_FLAGS_NO_MONEY)) if (peep->CashInPocket <= 0 && !(gParkFlags & PARK_FLAGS_NO_MONEY))
@@ -3856,7 +3856,7 @@ void Guest::UpdateRideFreeVehicleEnterRide(Ride* ride)
if (ridePrice != 0) if (ridePrice != 0)
{ {
if ((ItemStandardFlags & PEEP_ITEM_VOUCHER) && (VoucherType == VOUCHER_TYPE_RIDE_FREE) if ((ItemStandardFlags & PEEP_ITEM_VOUCHER) && (VoucherType == VOUCHER_TYPE_RIDE_FREE)
&& (VoucherArguments == CurrentRide)) && (VoucherRideId == CurrentRide))
{ {
ItemStandardFlags &= ~PEEP_ITEM_VOUCHER; ItemStandardFlags &= ~PEEP_ITEM_VOUCHER;
WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_INVENTORY; WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_INVENTORY;

View File

@@ -15,6 +15,7 @@
#include "../rct12/RCT12.h" #include "../rct12/RCT12.h"
#include "../ride/Ride.h" #include "../ride/Ride.h"
#include "../ride/RideTypes.h" #include "../ride/RideTypes.h"
#include "../ride/ShopItem.h"
#include "../world/Location.hpp" #include "../world/Location.hpp"
#include "../world/SpriteBase.h" #include "../world/SpriteBase.h"
@@ -743,7 +744,11 @@ struct Peep : SpriteBase
uint8_t AmountOfSouvenirs; uint8_t AmountOfSouvenirs;
uint8_t VandalismSeen; // 0xC0 vandalism thought timeout, 0x3F vandalism tiles seen uint8_t VandalismSeen; // 0xC0 vandalism thought timeout, 0x3F vandalism tiles seen
uint8_t VoucherType; uint8_t VoucherType;
uint8_t VoucherArguments; // ride_id or string_offset_id union
{
ride_id_t VoucherRideId;
ShopItemIndex VoucherShopItem;
};
uint8_t SurroundingsThoughtTimeout; uint8_t SurroundingsThoughtTimeout;
uint8_t Angriness; uint8_t Angriness;
uint8_t TimeLost; // the time the peep has been lost when it reaches 254 generates the lost thought uint8_t TimeLost; // the time the peep has been lost when it reaches 254 generates the lost thought

View File

@@ -1493,7 +1493,7 @@ private:
dst->PaidOnFood = src->paid_on_food; dst->PaidOnFood = src->paid_on_food;
dst->PaidOnSouvenirs = src->paid_on_souvenirs; dst->PaidOnSouvenirs = src->paid_on_souvenirs;
dst->VoucherArguments = src->voucher_arguments; dst->VoucherRideId = src->voucher_arguments;
dst->VoucherType = src->voucher_type; dst->VoucherType = src->voucher_type;
dst->SurroundingsThoughtTimeout = src->surroundings_thought_timeout; dst->SurroundingsThoughtTimeout = src->surroundings_thought_timeout;

View File

@@ -1228,7 +1228,7 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src)
dst->no_of_souvenirs = src->AmountOfSouvenirs; dst->no_of_souvenirs = src->AmountOfSouvenirs;
dst->vandalism_seen = src->VandalismSeen; dst->vandalism_seen = src->VandalismSeen;
dst->voucher_type = src->VoucherType; dst->voucher_type = src->VoucherType;
dst->voucher_arguments = src->VoucherArguments; dst->voucher_arguments = src->VoucherRideId;
dst->surroundings_thought_timeout = src->SurroundingsThoughtTimeout; dst->surroundings_thought_timeout = src->SurroundingsThoughtTimeout;
dst->angriness = src->Angriness; dst->angriness = src->Angriness;
dst->time_lost = src->TimeLost; dst->time_lost = src->TimeLost;

View File

@@ -1510,7 +1510,7 @@ public:
dst->AmountOfSouvenirs = src->no_of_souvenirs; dst->AmountOfSouvenirs = src->no_of_souvenirs;
dst->VandalismSeen = src->vandalism_seen; dst->VandalismSeen = src->vandalism_seen;
dst->VoucherType = src->voucher_type; dst->VoucherType = src->voucher_type;
dst->VoucherArguments = src->voucher_arguments; dst->VoucherRideId = src->voucher_arguments;
dst->SurroundingsThoughtTimeout = src->surroundings_thought_timeout; dst->SurroundingsThoughtTimeout = src->surroundings_thought_timeout;
dst->Angriness = src->angriness; dst->Angriness = src->angriness;
dst->TimeLost = src->time_lost; dst->TimeLost = src->time_lost;

View File

@@ -165,7 +165,7 @@ struct RideTypeDescriptor
money16 DefaultPrices[NUM_SHOP_ITEMS_PER_RIDE]; money16 DefaultPrices[NUM_SHOP_ITEMS_PER_RIDE];
uint8_t DefaultMusic; uint8_t DefaultMusic;
/** rct2: 0x0097D7CB */ /** rct2: 0x0097D7CB */
uint8_t PhotoItem; ShopItemIndex PhotoItem;
/** rct2: 0x0097D21E */ /** rct2: 0x0097D21E */
uint8_t BonusValue; uint8_t BonusValue;
track_colour_preset_list ColourPresets; track_colour_preset_list ColourPresets;

View File

@@ -11,6 +11,8 @@
#include "../common.h" #include "../common.h"
using ShopItemIndex = uint8_t;
struct Ride; struct Ride;
enum enum

View File

@@ -256,7 +256,7 @@ static void CompareSpriteDataPeep(const Peep& left, const Peep& right)
COMPARE_FIELD(AmountOfSouvenirs); COMPARE_FIELD(AmountOfSouvenirs);
COMPARE_FIELD(VandalismSeen); COMPARE_FIELD(VandalismSeen);
COMPARE_FIELD(VoucherType); COMPARE_FIELD(VoucherType);
COMPARE_FIELD(VoucherArguments); COMPARE_FIELD(VoucherRideId);
COMPARE_FIELD(SurroundingsThoughtTimeout); COMPARE_FIELD(SurroundingsThoughtTimeout);
COMPARE_FIELD(Angriness); COMPARE_FIELD(Angriness);
COMPARE_FIELD(TimeLost); COMPARE_FIELD(TimeLost);