mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
Adjust more constants to new constexpr notation (#22463)
* Rename DUCK_MAX_STATES to kDuckMaxStates * Rename DuckMoveOffset to kDuckMoveOffset * Rename DuckAnimationFlyToWater to kDuckAnimationFlyToWater * Rename DuckAnimationSwim to kDuckAnimationSwim * Rename DuckAnimationDrink to kDuckAnimationDrink * Rename DuckAnimationDoubleDrink to kDuckAnimationDoubleDrink * Rename DuckAnimationFlyAway to kDuckAnimationFlyAway * Rename DuckAnimations to kDuckAnimations * Rename ReplayVersion to kReplayVersion * Rename ReplayMagic to kReplayMagic * Rename ReplayCompressionLevel to kReplayCompressionLevel * Rename NormalRecordingChecksumTicks to kNormalRecordingChecksumTicks * Rename SilentRecordingChecksumTicks to kSilentRecordingChecksumTicks * Rename WindowButtonsOnTheLeftDefault to kWindowButtonsOnTheLeftDefault
This commit is contained in:
@@ -102,11 +102,11 @@ namespace OpenRCT2
|
||||
|
||||
class ReplayManager final : public IReplayManager
|
||||
{
|
||||
static constexpr uint16_t ReplayVersion = 10;
|
||||
static constexpr uint32_t ReplayMagic = 0x5243524F; // ORCR.
|
||||
static constexpr int ReplayCompressionLevel = 9;
|
||||
static constexpr int NormalRecordingChecksumTicks = 1;
|
||||
static constexpr int SilentRecordingChecksumTicks = 40; // Same as network server
|
||||
static constexpr uint16_t kReplayVersion = 10;
|
||||
static constexpr uint32_t kReplayMagic = 0x5243524F; // ORCR.
|
||||
static constexpr int kReplayCompressionLevel = 9;
|
||||
static constexpr int kNormalRecordingChecksumTicks = 1;
|
||||
static constexpr int kSilentRecordingChecksumTicks = 40; // Same as network server
|
||||
|
||||
enum class ReplayMode
|
||||
{
|
||||
@@ -241,8 +241,8 @@ namespace OpenRCT2
|
||||
const auto currentTicks = GetGameState().CurrentTicks;
|
||||
|
||||
auto replayData = std::make_unique<ReplayRecordData>();
|
||||
replayData->magic = ReplayMagic;
|
||||
replayData->version = ReplayVersion;
|
||||
replayData->magic = kReplayMagic;
|
||||
replayData->version = kReplayVersion;
|
||||
replayData->networkId = NetworkGetVersion();
|
||||
replayData->name = name;
|
||||
replayData->tickStart = currentTicks;
|
||||
@@ -320,7 +320,7 @@ namespace OpenRCT2
|
||||
auto compressBuf = std::make_unique<unsigned char[]>(compressLength);
|
||||
compress2(
|
||||
compressBuf.get(), &compressLength, static_cast<const unsigned char*>(stream.GetData()), stream.GetLength(),
|
||||
ReplayCompressionLevel);
|
||||
kReplayCompressionLevel);
|
||||
file.data.Write(compressBuf.get(), compressLength);
|
||||
|
||||
DataSerialiser fileSerialiser(true);
|
||||
@@ -522,9 +522,9 @@ namespace OpenRCT2
|
||||
{
|
||||
default:
|
||||
case RecordType::NORMAL:
|
||||
return NormalRecordingChecksumTicks;
|
||||
return kNormalRecordingChecksumTicks;
|
||||
case RecordType::SILENT:
|
||||
return SilentRecordingChecksumTicks;
|
||||
return kSilentRecordingChecksumTicks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -723,21 +723,21 @@ namespace OpenRCT2
|
||||
|
||||
bool Compatible(ReplayRecordData& data)
|
||||
{
|
||||
return data.version == ReplayVersion;
|
||||
return data.version == kReplayVersion;
|
||||
}
|
||||
|
||||
bool Serialise(DataSerialiser& serialiser, ReplayRecordData& data)
|
||||
{
|
||||
serialiser << data.magic;
|
||||
if (data.magic != ReplayMagic)
|
||||
if (data.magic != kReplayMagic)
|
||||
{
|
||||
LOG_ERROR("Magic does not match %08X, expected: %08X", data.magic, ReplayMagic);
|
||||
LOG_ERROR("Magic does not match %08X, expected: %08X", data.magic, kReplayMagic);
|
||||
return false;
|
||||
}
|
||||
serialiser << data.version;
|
||||
if (data.version != ReplayVersion && !Compatible(data))
|
||||
if (data.version != kReplayVersion && !Compatible(data))
|
||||
{
|
||||
LOG_ERROR("Invalid version detected %04X, expected: %04X", data.version, ReplayVersion);
|
||||
LOG_ERROR("Invalid version detected %04X, expected: %04X", data.version, kReplayVersion);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Ui;
|
||||
|
||||
#ifdef __APPLE__
|
||||
static constexpr bool WindowButtonsOnTheLeftDefault = true;
|
||||
static constexpr bool kWindowButtonsOnTheLeftDefault = true;
|
||||
#else
|
||||
static constexpr bool WindowButtonsOnTheLeftDefault = false;
|
||||
static constexpr bool kWindowButtonsOnTheLeftDefault = false;
|
||||
#endif
|
||||
#ifdef __ANDROID__
|
||||
static constexpr bool kEnlargedUiDefault = true;
|
||||
@@ -358,7 +358,7 @@ namespace OpenRCT2::Config
|
||||
model->ObjectSelectionFilterFlags = reader->GetInt32("object_selection_filter_flags", 0x3FFF);
|
||||
model->ScenarioselectLastTab = reader->GetInt32("scenarioselect_last_tab", 0);
|
||||
model->ListRideVehiclesSeparately = reader->GetBoolean("list_ride_vehicles_separately", false);
|
||||
model->WindowButtonsOnTheLeft = reader->GetBoolean("window_buttons_on_the_left", WindowButtonsOnTheLeftDefault);
|
||||
model->WindowButtonsOnTheLeft = reader->GetBoolean("window_buttons_on_the_left", kWindowButtonsOnTheLeftDefault);
|
||||
model->EnlargedUi = reader->GetBoolean("enlarged_ui", kEnlargedUiDefault);
|
||||
model->TouchEnhancements = reader->GetBoolean("touch_enhancements", kEnlargedUiDefault);
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
constexpr int32_t DUCK_MAX_STATES = 5;
|
||||
constexpr int32_t kDuckMaxStates = 5;
|
||||
|
||||
// clang-format off
|
||||
static constexpr CoordsXY DuckMoveOffset[] =
|
||||
static constexpr CoordsXY kDuckMoveOffset[] =
|
||||
{
|
||||
{ -1, 0 },
|
||||
{ 0, 1 },
|
||||
@@ -35,39 +35,39 @@ static constexpr CoordsXY DuckMoveOffset[] =
|
||||
{ 0, -1 },
|
||||
};
|
||||
|
||||
static constexpr uint8_t DuckAnimationFlyToWater[] =
|
||||
static constexpr uint8_t kDuckAnimationFlyToWater[] =
|
||||
{
|
||||
8, 9, 10, 11, 12, 13
|
||||
};
|
||||
|
||||
static constexpr uint8_t DuckAnimationSwim[] =
|
||||
static constexpr uint8_t kkDuckAnimationswim[] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
static constexpr uint8_t DuckAnimationDrink[] =
|
||||
static constexpr uint8_t kDuckAnimationDrink[] =
|
||||
{
|
||||
1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0xFF
|
||||
};
|
||||
|
||||
static constexpr uint8_t DuckAnimationDoubleDrink[] =
|
||||
static constexpr uint8_t kDuckAnimationDoubleDrink[] =
|
||||
{
|
||||
4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6,
|
||||
6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 0, 0, 0, 0, 0xFF
|
||||
};
|
||||
|
||||
static constexpr uint8_t DuckAnimationFlyAway[] =
|
||||
static constexpr uint8_t kDuckAnimationFlyAway[] =
|
||||
{
|
||||
8, 9, 10, 11, 12, 13
|
||||
};
|
||||
|
||||
static constexpr const uint8_t * DuckAnimations[] =
|
||||
static constexpr const uint8_t * kDuckAnimations[] =
|
||||
{
|
||||
DuckAnimationFlyToWater, // FLY_TO_WATER
|
||||
DuckAnimationSwim, // SWIM
|
||||
DuckAnimationDrink, // DRINK
|
||||
DuckAnimationDoubleDrink, // DOUBLE_DRINK
|
||||
DuckAnimationFlyAway, // FLY_AWAY
|
||||
kDuckAnimationFlyToWater, // FLY_TO_WATER
|
||||
kkDuckAnimationswim, // SWIM
|
||||
kDuckAnimationDrink, // DRINK
|
||||
kDuckAnimationDoubleDrink, // DOUBLE_DRINK
|
||||
kDuckAnimationFlyAway, // FLY_AWAY
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -95,7 +95,7 @@ void Duck::UpdateFlyToWater()
|
||||
return;
|
||||
|
||||
frame++;
|
||||
if (frame >= std::size(DuckAnimationFlyToWater))
|
||||
if (frame >= std::size(kDuckAnimationFlyToWater))
|
||||
{
|
||||
frame = 0;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ void Duck::UpdateFlyToWater()
|
||||
Invalidate();
|
||||
int32_t manhattanDistance = abs(target_x - x) + abs(target_y - y);
|
||||
int32_t direction = Orientation >> 3;
|
||||
auto destination = CoordsXYZ{ CoordsXY{ x, y } + DuckMoveOffset[direction], 0 };
|
||||
auto destination = CoordsXYZ{ CoordsXY{ x, y } + kDuckMoveOffset[direction], 0 };
|
||||
int32_t manhattanDistanceN = abs(target_x - destination.x) + abs(target_y - destination.y);
|
||||
|
||||
auto surfaceElement = MapGetSurfaceElementAt(CoordsXY{ target_x, target_y });
|
||||
@@ -204,7 +204,7 @@ void Duck::UpdateSwim()
|
||||
}
|
||||
|
||||
int32_t direction = Orientation >> 3;
|
||||
auto destination = CoordsXYZ{ CoordsXY{ x, y } + DuckMoveOffset[direction], 0 };
|
||||
auto destination = CoordsXYZ{ CoordsXY{ x, y } + kDuckMoveOffset[direction], 0 };
|
||||
landZ = TileElementHeight(destination);
|
||||
waterZ = TileElementWaterHeight(destination);
|
||||
|
||||
@@ -222,7 +222,7 @@ void Duck::UpdateSwim()
|
||||
void Duck::UpdateDrink()
|
||||
{
|
||||
frame++;
|
||||
if (DuckAnimationDrink[frame] == 0xFF)
|
||||
if (kDuckAnimationDrink[frame] == 0xFF)
|
||||
{
|
||||
state = DuckState::Swim;
|
||||
frame = 0;
|
||||
@@ -237,7 +237,7 @@ void Duck::UpdateDrink()
|
||||
void Duck::UpdateDoubleDrink()
|
||||
{
|
||||
frame++;
|
||||
if (DuckAnimationDoubleDrink[frame] == 0xFF)
|
||||
if (kDuckAnimationDoubleDrink[frame] == 0xFF)
|
||||
{
|
||||
state = DuckState::Swim;
|
||||
frame = 0;
|
||||
@@ -254,7 +254,7 @@ void Duck::UpdateFlyAway()
|
||||
if ((GetGameState().CurrentTicks & 3) == 0)
|
||||
{
|
||||
frame++;
|
||||
if (frame >= std::size(DuckAnimationFlyAway))
|
||||
if (frame >= std::size(kDuckAnimationFlyAway))
|
||||
{
|
||||
frame = 0;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ void Duck::UpdateFlyAway()
|
||||
Invalidate();
|
||||
|
||||
int32_t direction = Orientation >> 3;
|
||||
auto destination = CoordsXYZ{ x + (DuckMoveOffset[direction].x * 2), y + (DuckMoveOffset[direction].y * 2),
|
||||
auto destination = CoordsXYZ{ x + (kDuckMoveOffset[direction].x * 2), y + (kDuckMoveOffset[direction].y * 2),
|
||||
std::min<int32_t>(z + 2, 496) };
|
||||
if (MapIsLocationValid(destination))
|
||||
{
|
||||
@@ -278,10 +278,10 @@ void Duck::UpdateFlyAway()
|
||||
uint32_t Duck::GetFrameImage(int32_t direction) const
|
||||
{
|
||||
uint32_t imageId = 0;
|
||||
if (EnumValue(state) < DUCK_MAX_STATES)
|
||||
if (EnumValue(state) < kDuckMaxStates)
|
||||
{
|
||||
// TODO: Check frame is in range
|
||||
uint8_t imageOffset = DuckAnimations[EnumValue(state)][frame];
|
||||
uint8_t imageOffset = kDuckAnimations[EnumValue(state)][frame];
|
||||
imageId = SPR_DUCK + (imageOffset * 4) + (direction / 8);
|
||||
}
|
||||
return imageId;
|
||||
|
||||
Reference in New Issue
Block a user