mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #21818 from Harry-Hopkinson/refactor-constant-notation
Refactor constant notation in Chat.h and Peep.h
This commit is contained in:
commit
3d05fce68e
|
@ -978,10 +978,10 @@ static StringId window_cheats_page_titles[] = {
|
|||
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_HAPPINESS, 0);
|
||||
break;
|
||||
case WIDX_GUEST_ENERGY_MAX:
|
||||
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_ENERGY, PEEP_MAX_ENERGY);
|
||||
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_ENERGY, kPeepMaxEnergy);
|
||||
break;
|
||||
case WIDX_GUEST_ENERGY_MIN:
|
||||
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_ENERGY, PEEP_MIN_ENERGY);
|
||||
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_ENERGY, kPeepMinEnergy);
|
||||
break;
|
||||
case WIDX_GUEST_HUNGER_MAX:
|
||||
CheatsSet(CheatType::SetGuestParameter, GUEST_PARAMETER_HUNGER, 0);
|
||||
|
|
|
@ -1101,7 +1101,7 @@ static_assert(_guestWindowPageWidgets.size() == WINDOW_GUEST_PAGE_COUNT);
|
|||
screenCoords.y += LIST_ROW_HEIGHT;
|
||||
DrawTextBasic(dpi, screenCoords, STR_GUEST_STAT_ENERGY_LABEL);
|
||||
|
||||
int32_t energy = NormalizeGuestStatValue(peep->Energy - PEEP_MIN_ENERGY, PEEP_MAX_ENERGY - PEEP_MIN_ENERGY, 10);
|
||||
int32_t energy = NormalizeGuestStatValue(peep->Energy - kPeepMinEnergy, kPeepMaxEnergy - kPeepMinEnergy, 10);
|
||||
barColour = COLOUR_BRIGHT_GREEN;
|
||||
barBlink = energy < 50;
|
||||
StatsBarsDraw(energy, screenCoords, dpi, barColour, barBlink);
|
||||
|
|
|
@ -104,7 +104,7 @@ static Widget _windowServerStartWidgets[] = {
|
|||
WindowStartTextbox(*this, widgetIndex, STR_STRING, _description, MAX_SERVER_DESCRIPTION_LENGTH);
|
||||
break;
|
||||
case WIDX_GREETING_INPUT:
|
||||
WindowStartTextbox(*this, widgetIndex, STR_STRING, _greeting, CHAT_INPUT_SIZE);
|
||||
WindowStartTextbox(*this, widgetIndex, STR_STRING, _greeting, kChatInputSize);
|
||||
break;
|
||||
case WIDX_PASSWORD_INPUT:
|
||||
WindowStartTextbox(*this, widgetIndex, STR_STRING, _password, 32);
|
||||
|
@ -259,7 +259,7 @@ static Widget _windowServerStartWidgets[] = {
|
|||
char _port[7];
|
||||
char _name[65];
|
||||
char _description[MAX_SERVER_DESCRIPTION_LENGTH];
|
||||
char _greeting[CHAT_INPUT_SIZE];
|
||||
char _greeting[kChatInputSize];
|
||||
char _password[33];
|
||||
static void ScenarioSelectCallback(const utf8* path)
|
||||
{
|
||||
|
|
|
@ -353,7 +353,7 @@ ParametersRange CheatSetAction::GetParameterRange(CheatType cheatType) const
|
|||
{ 0, kPeepMaxHappiness } };
|
||||
case GUEST_PARAMETER_ENERGY:
|
||||
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY },
|
||||
{ PEEP_MIN_ENERGY, PEEP_MAX_ENERGY } };
|
||||
{ kPeepMinEnergy, kPeepMaxEnergy } };
|
||||
case GUEST_PARAMETER_HUNGER:
|
||||
return { { GUEST_PARAMETER_HAPPINESS, GUEST_PARAMETER_PREFERRED_RIDE_INTENSITY }, { 0, kPeepMaxHunger } };
|
||||
case GUEST_PARAMETER_THIRST:
|
||||
|
|
|
@ -838,16 +838,16 @@ void Guest::Loc68FA89()
|
|||
}
|
||||
else
|
||||
{
|
||||
newEnergy = std::min(PEEP_MAX_ENERGY_TARGET, newEnergy + 4);
|
||||
newEnergy = std::min<uint16_t>(kPeepMaxEnergyTarget, newEnergy + 4);
|
||||
if (newEnergy > newTargetEnergy)
|
||||
newEnergy = newTargetEnergy;
|
||||
}
|
||||
|
||||
if (newEnergy < PEEP_MIN_ENERGY)
|
||||
newEnergy = PEEP_MIN_ENERGY;
|
||||
if (newEnergy < kPeepMinEnergy)
|
||||
newEnergy = kPeepMinEnergy;
|
||||
|
||||
/* Previous code here suggested maximum energy is 128. */
|
||||
newEnergy = std::min(static_cast<uint8_t>(PEEP_MAX_ENERGY), newEnergy);
|
||||
newEnergy = std::min(kPeepMaxEnergy, newEnergy);
|
||||
|
||||
if (newEnergy != Energy)
|
||||
{
|
||||
|
@ -3035,7 +3035,7 @@ static void PeepUpdateHunger(Guest* peep)
|
|||
{
|
||||
peep->Hunger -= 2;
|
||||
|
||||
peep->EnergyTarget = std::min(peep->EnergyTarget + 2, PEEP_MAX_ENERGY_TARGET);
|
||||
peep->EnergyTarget = std::min<uint16_t>(peep->EnergyTarget + 2, kPeepMaxEnergyTarget);
|
||||
peep->Toilet = std::min(peep->Toilet + 1, 255);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
#include <array>
|
||||
#include <optional>
|
||||
|
||||
#define PEEP_MIN_ENERGY 32
|
||||
#define PEEP_MAX_ENERGY 128
|
||||
#define PEEP_MAX_ENERGY_TARGET 255 // Oddly, this differs from max energy!
|
||||
constexpr uint8_t kPeepMinEnergy = 32;
|
||||
constexpr uint8_t kPeepMaxEnergy = 128;
|
||||
constexpr uint8_t kPeepMaxEnergyTarget = 255; // Oddly, this differs from max energy!
|
||||
|
||||
constexpr auto PEEP_CLEARANCE_HEIGHT = 4 * COORDS_Z_STEP;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ bool ChatAvailable()
|
|||
void ChatOpen()
|
||||
{
|
||||
gChatOpen = true;
|
||||
_chatTextInputSession = ContextStartTextInput(_chatCurrentLine, CHAT_MAX_MESSAGE_LENGTH);
|
||||
_chatTextInputSession = ContextStartTextInput(_chatCurrentLine, kChatMaxMessageLength);
|
||||
}
|
||||
|
||||
void ChatClose()
|
||||
|
@ -97,7 +97,7 @@ void ChatDraw(DrawPixelInfo& dpi, uint8_t chatBackgroundColor)
|
|||
}
|
||||
|
||||
_chatLeft = 10;
|
||||
_chatRight = std::min((ContextGetWidth() - 10), CHAT_MAX_WINDOW_WIDTH);
|
||||
_chatRight = std::min<int16_t>((ContextGetWidth() - 10), kChatMaxWindowWidth);
|
||||
_chatWidth = _chatRight - _chatLeft;
|
||||
_chatBottom = ContextGetHeight() - 45;
|
||||
_chatTop = _chatBottom - 10;
|
||||
|
@ -158,7 +158,7 @@ void ChatDraw(DrawPixelInfo& dpi, uint8_t chatBackgroundColor)
|
|||
int32_t stringHeight = 0;
|
||||
|
||||
// Draw chat history
|
||||
for (size_t i = 0; i < CHAT_HISTORY_SIZE; i++, screenCoords.y -= stringHeight)
|
||||
for (size_t i = 0; i < kChatHistorySize; i++, screenCoords.y -= stringHeight)
|
||||
{
|
||||
if (i >= _chatHistory.size())
|
||||
break;
|
||||
|
@ -220,7 +220,7 @@ void ChatAddHistory(std::string_view s)
|
|||
std::string buffer = timeBuffer;
|
||||
buffer += s;
|
||||
|
||||
if (_chatHistory.size() >= CHAT_HISTORY_SIZE)
|
||||
if (_chatHistory.size() >= kChatHistorySize)
|
||||
{
|
||||
_chatHistory.pop_back();
|
||||
_chatHistoryTime.pop_back();
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
#include <string_view>
|
||||
|
||||
#define CHAT_HISTORY_SIZE 10
|
||||
#define CHAT_INPUT_SIZE 1024
|
||||
#define CHAT_MAX_MESSAGE_LENGTH 200
|
||||
#define CHAT_MAX_WINDOW_WIDTH 600
|
||||
constexpr int8_t kChatHistorySize = 10;
|
||||
constexpr int16_t kChatInputSize = 1024;
|
||||
constexpr uint8_t kChatMaxMessageLength = 200;
|
||||
constexpr int16_t kChatMaxWindowWidth = 600;
|
||||
|
||||
struct DrawPixelInfo;
|
||||
struct ScreenCoordsXY;
|
||||
|
|
Loading…
Reference in New Issue