Update constant notation in Entrance.h and NewsItem.h (#27317)

Part of #21432.
This commit is contained in:
anying authored and GitHub committed 2026-10-23 23:10:59 +02:00
1 parent f67b6891db
commit 47163dabbb
10 files changed
+34 -34

No files matched your search

+2 -2
View File
@@ -511,7 +511,7 @@ namespace OpenRCT2::Ui::Windows
auto borderStyle = Rectangle::BorderStyle::outset;
if (_pressedNewsItemIndex != -1)
{
News::IsValidIndex(_pressedNewsItemIndex + News::ItemHistoryStart);
News::IsValidIndex(_pressedNewsItemIndex + News::kItemHistoryStart);
if (i == _pressedNewsItemIndex && _pressedButtonIndex == 1)
{
borderStyle = Rectangle::BorderStyle::inset;
@@ -593,7 +593,7 @@ namespace OpenRCT2::Ui::Windows
auto borderStyle = Rectangle::BorderStyle::outset;
if (_pressedNewsItemIndex != -1)
{
News::IsValidIndex(_pressedNewsItemIndex + News::ItemHistoryStart);
News::IsValidIndex(_pressedNewsItemIndex + News::kItemHistoryStart);
if (i == _pressedNewsItemIndex && _pressedButtonIndex == 2)
borderStyle = Rectangle::BorderStyle::inset;
}
@@ -88,7 +88,7 @@ namespace OpenRCT2::GameActions
}
auto zLow = _loc.z;
auto zHigh = zLow + ParkEntranceHeight;
auto zHigh = zLow + kParkEntranceHeight;
CoordsXYZ entranceLoc = _loc;
for (uint8_t index = 0; index < 3; index++)
{
@@ -130,7 +130,7 @@ namespace OpenRCT2::GameActions
park.entrances.push_back(_loc);
auto zLow = _loc.z;
auto zHigh = zLow + ParkEntranceHeight;
auto zHigh = zLow + kParkEntranceHeight;
CoordsXY entranceLoc = { _loc.x, _loc.y };
constexpr auto kEntranceSequences = std::to_array(
@@ -117,7 +117,7 @@ namespace OpenRCT2::GameActions
{
return Result(Status::noFreeElements, errorTitle, STR_TILE_ELEMENT_LIMIT_REACHED);
}
auto clear_z = z + (_isExit ? RideExitHeight : RideEntranceHeight);
auto clear_z = z + (_isExit ? kRideExitHeight : kRideEntranceHeight);
auto canBuild = MapCanConstructWithClearAt(
{ _loc, z, clear_z }, MapPlaceNonSceneryClearFunc, { 0b1111, 0 }, GetFlags());
if (canBuild.error != Status::ok)
@@ -132,7 +132,7 @@ namespace OpenRCT2::GameActions
return Result(Status::disallowed, errorTitle, STR_RIDE_CANT_BUILD_THIS_UNDERWATER);
}
if (z > MaxRideEntranceOrExitHeight)
if (z > kMaxRideEntranceOrExitHeight)
{
return Result(Status::disallowed, errorTitle, STR_TOO_HIGH);
}
@@ -186,7 +186,7 @@ namespace OpenRCT2::GameActions
WallRemoveAtZ({ _loc, z });
}
auto clear_z = z + (_isExit ? RideExitHeight : RideEntranceHeight);
auto clear_z = z + (_isExit ? kRideExitHeight : kRideEntranceHeight);
auto canBuild = MapCanConstructWithClearAt(
{ _loc, z, clear_z }, MapPlaceNonSceneryClearFunc, { 0b1111, 0 }, GetFlags().with(CommandFlag::apply));
if (canBuild.error != Status::ok)
@@ -253,7 +253,7 @@ namespace OpenRCT2::GameActions
return Result(Status::noFreeElements, errorTitle, STR_TILE_ELEMENT_LIMIT_REACHED);
}
int16_t baseZ = loc.z;
int16_t clearZ = baseZ + (isExit ? RideExitHeight : RideEntranceHeight);
int16_t clearZ = baseZ + (isExit ? kRideExitHeight : kRideEntranceHeight);
auto canBuild = MapCanConstructWithClearAt({ loc, baseZ, clearZ }, MapPlaceNonSceneryClearFunc, { 0b1111, 0 }, {});
if (canBuild.error != Status::ok)
{
@@ -267,7 +267,7 @@ namespace OpenRCT2::GameActions
return Result(Status::disallowed, errorTitle, STR_RIDE_CANT_BUILD_THIS_UNDERWATER);
}
if (baseZ > MaxRideEntranceOrExitHeight)
if (baseZ > kMaxRideEntranceOrExitHeight)
{
return Result(Status::disallowed, errorTitle, STR_TOO_HIGH);
}
@@ -1623,7 +1623,7 @@ static void ConsoleCommandAddNewsItem([[maybe_unused]] InteractiveConsole& conso
if (argv.size() < 2)
{
console.WriteLineWarning("Too few arguments");
static_assert(News::ItemTypeCount == 11, "News::ItemType::count changed, update console command!");
static_assert(News::kItemTypeCount == 11, "News::ItemType::count changed, update console command!");
console.WriteLine("add_news_item <type> <message> [assoc]");
console.WriteLine("type is one of:");
console.WriteLine(" 0 (News::ItemType::null)");
+6 -6
View File
@@ -44,7 +44,7 @@ const News::Item& News::ItemQueues::current() const
bool News::IsValidIndex(int32_t index)
{
if (index >= MaxItems)
if (index >= kMaxItems)
{
LOG_ERROR("Tried to get news item past MAX_NEWS.");
return false;
@@ -466,14 +466,14 @@ void News::AddItemToQueue(ItemQueues& queues, Item* newNewsItem)
void News::RemoveItem(ItemQueues& queues, int32_t index)
{
if (index < 0 || index >= MaxItems)
if (index < 0 || index >= kMaxItems)
return;
// News item is already null, no need to remove it
if (queues[index].type == ItemType::null)
return;
size_t newsBoundary = index < ItemHistoryStart ? ItemHistoryStart : MaxItems;
size_t newsBoundary = index < kItemHistoryStart ? kItemHistoryStart : kMaxItems;
for (size_t i = index; i < newsBoundary - 1; i++)
{
queues[i] = queues[i + 1];
@@ -485,12 +485,12 @@ void News::importNewsItems(ItemQueues& queues, const std::span<const Item> recen
{
queues.clear();
for (size_t i = 0; i < std::min<size_t>(recent.size(), ItemHistoryStart); i++)
for (size_t i = 0; i < std::min<size_t>(recent.size(), kItemHistoryStart); i++)
{
queues[i] = recent[i];
}
for (size_t i = 0; i < std::min<size_t>(archived.size(), MaxItemsArchive); i++)
for (size_t i = 0; i < std::min<size_t>(archived.size(), kMaxItemsArchive); i++)
{
queues[ItemHistoryStart + i] = archived[i];
queues[kItemHistoryStart + i] = archived[i];
}
}
+6 -6
View File
@@ -50,7 +50,7 @@ namespace OpenRCT2::News
count
};
constexpr size_t ItemTypeCount = static_cast<size_t>(ItemType::count);
constexpr size_t kItemTypeCount = static_cast<size_t>(ItemType::count);
enum ItemTypeProperty : uint8_t
{
@@ -126,9 +126,9 @@ namespace OpenRCT2::News
}
};
constexpr int32_t ItemHistoryStart = 11;
constexpr int32_t MaxItemsArchive = 50;
constexpr int32_t MaxItems = ItemHistoryStart + MaxItemsArchive;
constexpr int32_t kItemHistoryStart = 11;
constexpr int32_t kMaxItemsArchive = 50;
constexpr int32_t kMaxItems = kItemHistoryStart + kMaxItemsArchive;
template<std::size_t N>
class ItemQueue
@@ -296,8 +296,8 @@ namespace OpenRCT2::News
private:
int32_t removeTime() const;
ItemQueue<ItemHistoryStart> _recent;
ItemQueue<MaxItemsArchive> _archived;
ItemQueue<kItemHistoryStart> _recent;
ItemQueue<kMaxItemsArchive> _archived;
};
void InitQueue(Park::ParkData& park);
+1 -1
View File
@@ -315,7 +315,7 @@ namespace OpenRCT2::RCT2
if (src.Type == 0)
break;
if (src.Type >= News::ItemTypeCount)
if (src.Type >= News::kItemTypeCount)
{
LOG_ERROR("Invalid news type 0x%x for news item %d, ignoring remaining news items", src.Type, index);
break;
@@ -363,7 +363,7 @@ namespace OpenRCT2::Scripting
}
for (size_t i = 0, newsSize = newsItems.getArchived().size(); i < newsSize; i++)
{
auto offset = i + News::ItemHistoryStart;
auto offset = i + News::kItemHistoryStart;
JS_SetPropertyInt64(ctx, result, resultIdx++, gScParkMessage.New(ctx, offset));
}
return result;
@@ -372,14 +372,14 @@ namespace OpenRCT2::Scripting
JSValue ScPark::messages_set(JSContext* ctx, JSValue thisVal, JSValue value)
{
int32_t index = 0;
int32_t archiveIndex = News::ItemHistoryStart;
int32_t archiveIndex = News::kItemHistoryStart;
auto& newsItems = getGameState().park.newsItems;
JSIterateArray(ctx, value, [&index, &archiveIndex, &newsItems](JSContext* ctx2, JSValue item) {
auto isArchived = AsOrDefault(ctx2, item, "isArchived", false);
auto newsItem = NewsItemFromJS(ctx2, item);
if (isArchived)
{
if (archiveIndex < News::MaxItems)
if (archiveIndex < News::kMaxItems)
{
newsItems[archiveIndex] = newsItem;
archiveIndex++;
@@ -387,7 +387,7 @@ namespace OpenRCT2::Scripting
}
else
{
if (index < News::ItemHistoryStart)
if (index < News::kItemHistoryStart)
{
newsItems[index] = newsItem;
index++;
@@ -396,11 +396,11 @@ namespace OpenRCT2::Scripting
});
// End the lists by setting next item to null
if (index < News::ItemHistoryStart)
if (index < News::kItemHistoryStart)
{
newsItems[index].type = News::ItemType::null;
}
if (archiveIndex < News::MaxItems)
if (archiveIndex < News::kMaxItems)
{
newsItems[archiveIndex].type = News::ItemType::null;
}
@@ -29,7 +29,7 @@ namespace OpenRCT2::Scripting
JSValue ScParkMessage::isArchived_get(JSContext* ctx, JSValue thisVal)
{
auto index = gScParkMessage.GetOpaque<OpaqueParkMessageData*>(thisVal)->index;
return JS_NewBool(ctx, index >= News::ItemHistoryStart);
return JS_NewBool(ctx, index >= News::kItemHistoryStart);
}
JSValue ScParkMessage::month_get(JSContext* ctx, JSValue thisVal)
+4 -4
View File
@@ -16,14 +16,14 @@ struct CoordsXYE;
struct CoordsXYZ;
struct CoordsXYZD;
constexpr uint8_t ParkEntranceHeight = 12 * kCoordsZStep;
constexpr uint8_t RideEntranceHeight = 7 * kCoordsZStep;
constexpr uint8_t RideExitHeight = 5 * kCoordsZStep;
constexpr uint8_t kParkEntranceHeight = 12 * kCoordsZStep;
constexpr uint8_t kRideEntranceHeight = 7 * kCoordsZStep;
constexpr uint8_t kRideExitHeight = 5 * kCoordsZStep;
extern bool gParkEntranceGhostExists;
extern CoordsXYZD gParkEntranceGhostPosition;
constexpr int32_t MaxRideEntranceOrExitHeight = 244 * kCoordsZStep;
constexpr int32_t kMaxRideEntranceOrExitHeight = 244 * kCoordsZStep;
extern CoordsXYZD gRideEntranceExitGhostPosition;
extern StationIndex gRideEntranceExitGhostStationIndex;