Replace notation in Guest.h

This commit is contained in:
Harry Hopkinson 2024-04-15 15:48:41 +01:00 committed by GitHub
parent 8a2afbd1a3
commit 530a7de98f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 63 additions and 63 deletions

View File

@ -972,7 +972,7 @@ static StringId window_cheats_page_titles[] = {
switch (widgetIndex)
{
case WIDX_GUEST_HAPPINESS_MAX:
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_HAPPINESS, PEEP_MAX_HAPPINESS);
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_HAPPINESS, kPeepMaxHappiness);
break;
case WIDX_GUEST_HAPPINESS_MIN:
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_HAPPINESS, 0);
@ -987,16 +987,16 @@ static StringId window_cheats_page_titles[] = {
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_HUNGER, 0);
break;
case WIDX_GUEST_HUNGER_MIN:
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_HUNGER, PEEP_MAX_HUNGER);
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_HUNGER, kPeepMaxHunger);
break;
case WIDX_GUEST_THIRST_MAX:
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_THIRST, 0);
break;
case WIDX_GUEST_THIRST_MIN:
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_THIRST, PEEP_MAX_THIRST);
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_THIRST, kPeepMaxThirst);
break;
case WIDX_GUEST_NAUSEA_MAX:
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_NAUSEA, PEEP_MAX_NAUSEA);
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_NAUSEA, kPeepMaxNausea);
break;
case WIDX_GUEST_NAUSEA_MIN:
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_NAUSEA, 0);
@ -1010,7 +1010,7 @@ static StringId window_cheats_page_titles[] = {
CheatType::SetGuestParameter, GUEST_PARAMETER_NAUSEA_TOLERANCE, EnumValue(PeepNauseaTolerance::None));
break;
case WIDX_GUEST_TOILET_MAX:
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_TOILET, PEEP_MAX_TOILET);
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_TOILET, kPeepMaxToilet);
break;
case WIDX_GUEST_TOILET_MIN:
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_TOILET, 0);

View File

@ -792,7 +792,7 @@ static_assert(_guestWindowPageWidgets.size() == WINDOW_GUEST_PAGE_COUNT);
}
int32_t i = 0;
for (; i < PEEP_MAX_THOUGHTS; ++i)
for (; i < kPeepMaxThoughts; ++i)
{
if (peep->Thoughts[i].type == PeepThoughtType::None)
{
@ -804,7 +804,7 @@ static_assert(_guestWindowPageWidgets.size() == WINDOW_GUEST_PAGE_COUNT);
break;
}
}
if (i == PEEP_MAX_THOUGHTS)
if (i == kPeepMaxThoughts)
{
_marqueePosition = 0;
return;
@ -1092,7 +1092,7 @@ static_assert(_guestWindowPageWidgets.size() == WINDOW_GUEST_PAGE_COUNT);
// Happiness
DrawTextBasic(dpi, screenCoords, STR_GUEST_STAT_HAPPINESS_LABEL);
int32_t happiness = NormalizeGuestStatValue(peep->Happiness, PEEP_MAX_HAPPINESS, 10);
int32_t happiness = NormalizeGuestStatValue(peep->Happiness, kPeepMaxHappiness, 10);
int32_t barColour = COLOUR_BRIGHT_GREEN;
bool barBlink = happiness < 50;
StatsBarsDraw(happiness, screenCoords, dpi, barColour, barBlink);

View File

@ -356,7 +356,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots
COMPARE_FIELD(Guest, RejoinQueueTimeout);
COMPARE_FIELD(Guest, PreviousRide);
COMPARE_FIELD(Guest, PreviousRideTimeOut);
for (std::size_t i = 0; i < PEEP_MAX_THOUGHTS; i++)
for (std::size_t i = 0; i < kPeepMaxThoughts; i++)
{
COMPARE_FIELD(Guest, Thoughts[i].type);
COMPARE_FIELD(Guest, Thoughts[i].item);

View File

@ -350,21 +350,21 @@ ParametersRange CheatSetAction::GetParameterRange(CheatType cheatType) const
{
case GUEST_PARAMETER_HAPPINESS:
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY },
{ 0, PEEP_MAX_HAPPINESS } };
{ 0, kPeepMaxHappiness } };
case GUEST_PARAMETER_ENERGY:
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY },
{ PEEP_MIN_ENERGY, PEEP_MAX_ENERGY } };
case GUEST_PARAMETER_HUNGER:
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY }, { 0, PEEP_MAX_HUNGER } };
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY }, { 0, kPeepMaxHunger } };
case GUEST_PARAMETER_THIRST:
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY }, { 0, PEEP_MAX_THIRST } };
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY }, { 0, kPeepMaxThirst } };
case GUEST_PARAMETER_NAUSEA:
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY }, { 0, PEEP_MAX_NAUSEA } };
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY }, { 0, kPeepMaxNausea } };
case GUEST_PARAMETER_NAUSEA_TOLERANCE:
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY },
{ EnumValue(PeepNauseaTolerance::None), EnumValue(PeepNauseaTolerance::High) } };
case GUEST_PARAMETER_TOILET:
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY }, { 0, PEEP_MAX_TOILET } };
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY }, { 0, kPeepMaxToilet } };
case GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY:
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY }, { 0, 255 } };
default:

View File

@ -973,7 +973,7 @@ void Guest::Tick128UpdateGuest(uint32_t index)
if (thought_type != PeepThoughtType::None)
{
InsertNewThought(thought_type);
HappinessTarget = std::min(PEEP_MAX_HAPPINESS, HappinessTarget + 45);
HappinessTarget = std::min(kPeepMaxHappiness, HappinessTarget + 45);
}
}
}
@ -1596,8 +1596,8 @@ bool Guest::DecideAndBuyItem(Ride& ride, const ShopItem shopItem, money64 price)
}
int32_t happinessGrowth = itemValue * 4;
HappinessTarget = std::min((HappinessTarget + happinessGrowth), PEEP_MAX_HAPPINESS);
Happiness = std::min((Happiness + happinessGrowth), PEEP_MAX_HAPPINESS);
HappinessTarget = std::min((HappinessTarget + happinessGrowth), kPeepMaxHappiness);
Happiness = std::min((Happiness + happinessGrowth), kPeepMaxHappiness);
}
// reset itemValue for satisfaction calculation
@ -1744,7 +1744,7 @@ void Guest::OnEnterRide(Ride& ride)
SetHasRidden(ride);
PeepUpdateFavouriteRide(this, ride);
HappinessTarget = std::clamp(HappinessTarget + satisfaction, 0, PEEP_MAX_HAPPINESS);
HappinessTarget = std::clamp(HappinessTarget + satisfaction, 0, kPeepMaxHappiness);
PeepUpdateRideNauseaGrowth(this, ride);
}
@ -2695,7 +2695,7 @@ static int16_t PeepCalculateRideSatisfaction(Guest* peep, const Ride& ride)
static void PeepUpdateFavouriteRide(Guest* peep, const Ride& ride)
{
peep->PeepFlags &= ~PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE;
uint8_t peepRideRating = std::clamp((ride.excitement / 4) + peep->Happiness, 0, PEEP_MAX_HAPPINESS);
uint8_t peepRideRating = std::clamp((ride.excitement / 4) + peep->Happiness, 0, kPeepMaxHappiness);
if (peepRideRating >= peep->FavouriteRideRating)
{
if (peep->Happiness >= 160 && peep->HappinessTarget >= 160)
@ -3270,7 +3270,7 @@ void Guest::StopPurchaseThought(ride_type_t rideType)
}
// Remove the related thought
for (int32_t i = 0; i < PEEP_MAX_THOUGHTS; ++i)
for (int32_t i = 0; i < kPeepMaxThoughts; ++i)
{
PeepThought* thought = &Thoughts[i];
@ -3280,12 +3280,12 @@ void Guest::StopPurchaseThought(ride_type_t rideType)
if (thought->type != thoughtType)
continue;
if (i < PEEP_MAX_THOUGHTS - 1)
if (i < kPeepMaxThoughts - 1)
{
memmove(thought, thought + 1, sizeof(PeepThought) * (PEEP_MAX_THOUGHTS - i - 1));
memmove(thought, thought + 1, sizeof(PeepThought) * (kPeepMaxThoughts - i - 1));
}
Thoughts[PEEP_MAX_THOUGHTS - 1].type = PeepThoughtType::None;
Thoughts[kPeepMaxThoughts - 1].type = PeepThoughtType::None;
WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_THOUGHTS;
i--;
@ -5098,7 +5098,7 @@ void Guest::UpdateRideShopInteract()
RideSubState = PeepRideSubState::LeaveShop;
SetDestination({ tileCentreX, tileCentreY }, 3);
HappinessTarget = std::min(HappinessTarget + 30, PEEP_MAX_HAPPINESS);
HappinessTarget = std::min(HappinessTarget + 30, kPeepMaxHappiness);
Happiness = HappinessTarget;
}
else
@ -5125,7 +5125,7 @@ void Guest::UpdateRideShopInteract()
SetDestination({ tileCentreX, tileCentreY }, 3);
HappinessTarget = std::min(HappinessTarget + 30, PEEP_MAX_HAPPINESS);
HappinessTarget = std::min(HappinessTarget + 30, kPeepMaxHappiness);
Happiness = HappinessTarget;
StopPurchaseThought(ride->type);
}
@ -6963,7 +6963,7 @@ void Guest::InsertNewThought(PeepThoughtType thoughtType, uint16_t thoughtArgume
UpdateCurrentActionSpriteType();
}
for (int32_t i = 0; i < PEEP_MAX_THOUGHTS; ++i)
for (int32_t i = 0; i < kPeepMaxThoughts; ++i)
{
PeepThought* thought = &Thoughts[i];
// Remove the oldest thought by setting it to NONE.
@ -6975,15 +6975,15 @@ void Guest::InsertNewThought(PeepThoughtType thoughtType, uint16_t thoughtArgume
// If the thought type has not changed then we need to move
// it to the top of the thought list. This is done by first removing the
// existing thought and placing it at the top.
if (i < PEEP_MAX_THOUGHTS - 2)
if (i < kPeepMaxThoughts - 2)
{
memmove(thought, thought + 1, sizeof(PeepThought) * (PEEP_MAX_THOUGHTS - i - 1));
memmove(thought, thought + 1, sizeof(PeepThought) * (kPeepMaxThoughts - i - 1));
}
break;
}
}
memmove(&std::get<1>(Thoughts), &std::get<0>(Thoughts), sizeof(PeepThought) * (PEEP_MAX_THOUGHTS - 1));
memmove(&std::get<1>(Thoughts), &std::get<0>(Thoughts), sizeof(PeepThought) * (kPeepMaxThoughts - 1));
auto& thought = std::get<0>(Thoughts);
thought.type = thoughtType;
@ -7181,7 +7181,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
/* Initial value will vary by -15..16 */
int8_t happinessDelta = (ScenarioRand() & 0x1F) - 15;
/* Adjust by the delta, clamping at min=0 and max=255. */
peep->Happiness = std::clamp(peep->Happiness + happinessDelta, 0, PEEP_MAX_HAPPINESS);
peep->Happiness = std::clamp(peep->Happiness + happinessDelta, 0, kPeepMaxHappiness);
peep->HappinessTarget = peep->Happiness;
peep->Nausea = 0;
peep->NauseaTarget = 0;
@ -7193,7 +7193,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
/* Initial value will vary by -15..16 */
int8_t hungerDelta = (ScenarioRand() & 0x1F) - 15;
/* Adjust by the delta, clamping at min=0 and max=255. */
peep->Hunger = std::clamp(peep->Hunger + hungerDelta, 0, PEEP_MAX_HUNGER);
peep->Hunger = std::clamp(peep->Hunger + hungerDelta, 0, kPeepMaxHunger);
/* Scenario editor limits initial guest thirst to between 37..253.
* To be on the safe side, assume the value could have been hacked
@ -7202,7 +7202,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
/* Initial value will vary by -15..16 */
int8_t thirstDelta = (ScenarioRand() & 0x1F) - 15;
/* Adjust by the delta, clamping at min=0 and max=255. */
peep->Thirst = std::clamp(peep->Thirst + thirstDelta, 0, PEEP_MAX_THIRST);
peep->Thirst = std::clamp(peep->Thirst + thirstDelta, 0, kPeepMaxThirst);
peep->Toilet = 0;
peep->TimeToConsume = 0;

View File

@ -15,23 +15,23 @@
#include "../ride/ShopItem.h"
#include "Peep.h"
#define PEEP_MAX_THOUGHTS 5
constexpr int8_t kPeepMaxThoughts = 5;
#define PEEP_HUNGER_WARNING_THRESHOLD 25
#define PEEP_THIRST_WARNING_THRESHOLD 25
#define PEEP_TOILET_WARNING_THRESHOLD 28
#define PEEP_LITTER_WARNING_THRESHOLD 23
#define PEEP_DISGUST_WARNING_THRESHOLD 22
#define PEEP_VANDALISM_WARNING_THRESHOLD 15
#define PEEP_NOEXIT_WARNING_THRESHOLD 8
#define PEEP_LOST_WARNING_THRESHOLD 8
#define PEEP_TOO_LONG_QUEUE_THRESHOLD 25
constexpr int8_t kPeepHungerWarningThreshold = 25;
constexpr int8_t kPeepThirstWarningThreshold = 25;
constexpr int8_t kPeepToiletWarningThreshold = 28;
constexpr int8_t kPeepLitterWarningThreshold = 23;
constexpr int8_t kPeepDisgustWarningThreshold = 22;
constexpr int8_t kPeepVandalismWarningThreshold = 15;
constexpr int8_t kPeepNoExitWarningThreshold = 8;
constexpr int8_t kPeepLostWarningThreshold = 8;
constexpr int8_t kPeepTooLongQueueThreshold = 25;
#define PEEP_MAX_HAPPINESS 255
#define PEEP_MAX_HUNGER 255
#define PEEP_MAX_TOILET 255
#define PEEP_MAX_NAUSEA 255
#define PEEP_MAX_THIRST 255
constexpr int kPeepMaxHappiness = 255;
constexpr int kPeepMaxHunger = 255;
constexpr int16_t kPeepMaxToilet = 255;
constexpr int16_t kPeepMaxNausea = 255;
constexpr int kPeepMaxThirst = 255;
enum class PeepThoughtType : uint8_t
{
@ -294,7 +294,7 @@ public:
int8_t RejoinQueueTimeout; // whilst waiting for a free vehicle (or pair) in the entrance
RideId PreviousRide;
uint16_t PreviousRideTimeOut;
std::array<PeepThought, PEEP_MAX_THOUGHTS> Thoughts;
std::array<PeepThought, kPeepMaxThoughts> Thoughts;
// 0x3F Litter Count split into lots of 3 with time, 0xC0 Time since last recalc
uint8_t LitterCount;
// 0x3F Sick Count split into lots of 3 with time, 0xC0 Time since last recalc

View File

@ -868,7 +868,7 @@ static void GuestUpdateThoughts(Guest* peep)
// a holding zone. Before it becomes fresh.
int32_t add_fresh = 1;
int32_t fresh_thought = -1;
for (int32_t i = 0; i < PEEP_MAX_THOUGHTS; i++)
for (int32_t i = 0; i < kPeepMaxThoughts; i++)
{
if (peep->Thoughts[i].type == PeepThoughtType::None)
break;
@ -896,11 +896,11 @@ static void GuestUpdateThoughts(Guest* peep)
peep->WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_THOUGHTS;
// Clear top thought, push others up
if (i < PEEP_MAX_THOUGHTS - 2)
if (i < kPeepMaxThoughts - 2)
{
memmove(&peep->Thoughts[i], &peep->Thoughts[i + 1], sizeof(PeepThought) * (PEEP_MAX_THOUGHTS - i - 1));
memmove(&peep->Thoughts[i], &peep->Thoughts[i + 1], sizeof(PeepThought) * (kPeepMaxThoughts - i - 1));
}
peep->Thoughts[PEEP_MAX_THOUGHTS - 1].type = PeepThoughtType::None;
peep->Thoughts[kPeepMaxThoughts - 1].type = PeepThoughtType::None;
}
}
}
@ -1093,7 +1093,7 @@ void PeepProblemWarningsUpdate()
// could maybe be packed into a loop, would lose a lot of clarity though
if (warningThrottle[0])
--warningThrottle[0];
else if (hungerCounter >= PEEP_HUNGER_WARNING_THRESHOLD && hungerCounter >= gameState.NumGuestsInPark / 16)
else if (hungerCounter >= kPeepHungerWarningThreshold && hungerCounter >= gameState.NumGuestsInPark / 16)
{
warningThrottle[0] = 4;
if (gConfigNotifications.GuestWarnings)
@ -1105,7 +1105,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[1])
--warningThrottle[1];
else if (thirstCounter >= PEEP_THIRST_WARNING_THRESHOLD && thirstCounter >= gameState.NumGuestsInPark / 16)
else if (thirstCounter >= kPeepThirstWarningThreshold && thirstCounter >= gameState.NumGuestsInPark / 16)
{
warningThrottle[1] = 4;
if (gConfigNotifications.GuestWarnings)
@ -1117,7 +1117,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[2])
--warningThrottle[2];
else if (toiletCounter >= PEEP_TOILET_WARNING_THRESHOLD && toiletCounter >= gameState.NumGuestsInPark / 16)
else if (toiletCounter >= kPeepToiletWarningThreshold && toiletCounter >= gameState.NumGuestsInPark / 16)
{
warningThrottle[2] = 4;
if (gConfigNotifications.GuestWarnings)
@ -1129,7 +1129,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[3])
--warningThrottle[3];
else if (litterCounter >= PEEP_LITTER_WARNING_THRESHOLD && litterCounter >= gameState.NumGuestsInPark / 32)
else if (litterCounter >= kPeepLitterWarningThreshold && litterCounter >= gameState.NumGuestsInPark / 32)
{
warningThrottle[3] = 4;
if (gConfigNotifications.GuestWarnings)
@ -1141,7 +1141,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[4])
--warningThrottle[4];
else if (disgustCounter >= PEEP_DISGUST_WARNING_THRESHOLD && disgustCounter >= gameState.NumGuestsInPark / 32)
else if (disgustCounter >= kPeepDisgustWarningThreshold && disgustCounter >= gameState.NumGuestsInPark / 32)
{
warningThrottle[4] = 4;
if (gConfigNotifications.GuestWarnings)
@ -1153,7 +1153,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[5])
--warningThrottle[5];
else if (vandalismCounter >= PEEP_VANDALISM_WARNING_THRESHOLD && vandalismCounter >= gameState.NumGuestsInPark / 32)
else if (vandalismCounter >= kPeepVandalismWarningThreshold && vandalismCounter >= gameState.NumGuestsInPark / 32)
{
warningThrottle[5] = 4;
if (gConfigNotifications.GuestWarnings)
@ -1165,7 +1165,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[6])
--warningThrottle[6];
else if (noexitCounter >= PEEP_NOEXIT_WARNING_THRESHOLD)
else if (noexitCounter >= kPeepNoExitWarningThreshold)
{
warningThrottle[6] = 4;
if (gConfigNotifications.GuestWarnings)
@ -1174,7 +1174,7 @@ void PeepProblemWarningsUpdate()
News::AddItemToQueue(News::ItemType::Peeps, STR_PEEPS_GETTING_LOST_OR_STUCK, thoughtId, {});
}
}
else if (lostCounter >= PEEP_LOST_WARNING_THRESHOLD)
else if (lostCounter >= kPeepLostWarningThreshold)
{
warningThrottle[6] = 4;
if (gConfigNotifications.GuestWarnings)
@ -1186,7 +1186,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[7])
--warningThrottle[7];
else if (tooLongQueueCounter > PEEP_TOO_LONG_QUEUE_THRESHOLD && tooLongQueueCounter > inQueueCounter / 20)
else if (tooLongQueueCounter > kPeepTooLongQueueThreshold && tooLongQueueCounter > inQueueCounter / 20)
{ // The amount of guests complaining about queue duration is at least 5% of the amount of queuing guests.
// This includes guests who are no longer queuing.
warningThrottle[7] = 4;

View File

@ -896,12 +896,12 @@ void Staff::EntertainerUpdateNearbyPeeps() const
if (guest->State == PeepState::Walking)
{
guest->HappinessTarget = std::min(guest->HappinessTarget + 4, PEEP_MAX_HAPPINESS);
guest->HappinessTarget = std::min(guest->HappinessTarget + 4, kPeepMaxHappiness);
}
else if (guest->State == PeepState::Queuing)
{
guest->TimeInQueue = std::max(0, guest->TimeInQueue - 200);
guest->HappinessTarget = std::min(guest->HappinessTarget + 3, PEEP_MAX_HAPPINESS);
guest->HappinessTarget = std::min(guest->HappinessTarget + 3, kPeepMaxHappiness);
}
}
}