mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-24 07:14:31 +01:00
* refactor: integrated PEEP_ITEM into SHOP_ITEM * refactor: converted merged enum to flag Only former occurrences of PEEP_ITEM * cleanUp: code cleaned after merging * refactor: converted ShopItem to strong enum code reformatting * refactor: ShopItem enum items renamed code formatted * refactor: new getter and setter functions for Item...Flags * refactor: replaced all occurrences of ItemStandardFlags with appropriate getter and setter functions. COMPARE_FIELD macro needs to be commented out or the flag has to stay public. * refactor: all occurrences of ItemExtraFlags replaced with proper function calls. COMPARE_FIELD macro issue not resolved. * refactor: introduced new variable for unified item flags * refactor: adapted accessor functions accessor functions were modified to accommodate both standard and extra ShopItem flags * refactor: ItemExtraFlags accessor functions are replaced with general functions * refactor: reverted to original uint32_t flag variables * refactor: implemented suggested changes * refactor: integrate additional comments * refactor: incorporated requested changes * refactor: incorporated requested changes added static_cast<PeepThoughtType> in lines 1572 and 1590
This commit is contained in:
@@ -83,8 +83,8 @@ void RideObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||
_legacyType.max_height = stream->ReadValue<uint8_t>();
|
||||
// Skipping a uint64_t for the enabled track pieces and two uint8_ts for the categories.
|
||||
stream->Seek(10, STREAM_SEEK_CURRENT);
|
||||
_legacyType.shop_item[0] = stream->ReadValue<uint8_t>();
|
||||
_legacyType.shop_item[1] = stream->ReadValue<uint8_t>();
|
||||
_legacyType.shop_item[0] = static_cast<ShopItem>(stream->ReadValue<uint8_t>());
|
||||
_legacyType.shop_item[1] = static_cast<ShopItem>(stream->ReadValue<uint8_t>());
|
||||
|
||||
GetStringTable().Read(context, stream, ObjectStringID::NAME);
|
||||
GetStringTable().Read(context, stream, ObjectStringID::DESCRIPTION);
|
||||
@@ -557,7 +557,7 @@ void RideObject::ReadJson(IReadObjectContext* context, json_t& root)
|
||||
// This needs to be set for both shops/facilities _and_ regular rides.
|
||||
for (auto& item : _legacyType.shop_item)
|
||||
{
|
||||
item = SHOP_ITEM_NONE;
|
||||
item = ShopItem::None;
|
||||
}
|
||||
|
||||
auto carColours = Json::AsArray(properties["carColours"]);
|
||||
@@ -584,7 +584,7 @@ void RideObject::ReadJson(IReadObjectContext* context, json_t& root)
|
||||
for (size_t i = 0; i < numShopItems; i++)
|
||||
{
|
||||
auto shopItem = ParseShopItem(Json::GetString(rideSells[i]));
|
||||
if (shopItem == SHOP_ITEM_NONE)
|
||||
if (shopItem == ShopItem::None)
|
||||
{
|
||||
context->LogWarning(ObjectError::InvalidProperty, "Unknown shop item");
|
||||
}
|
||||
@@ -1037,47 +1037,47 @@ uint8_t RideObject::ParseRideCategory(const std::string& s)
|
||||
return (result != LookupTable.end()) ? result->second : static_cast<uint8_t>(RIDE_CATEGORY_TRANSPORT);
|
||||
}
|
||||
|
||||
uint8_t RideObject::ParseShopItem(const std::string& s)
|
||||
ShopItem RideObject::ParseShopItem(const std::string& s)
|
||||
{
|
||||
static const std::unordered_map<std::string, uint8_t> LookupTable{
|
||||
{ "burger", SHOP_ITEM_BURGER },
|
||||
{ "chips", SHOP_ITEM_CHIPS },
|
||||
{ "ice_cream", SHOP_ITEM_ICE_CREAM },
|
||||
{ "candyfloss", SHOP_ITEM_CANDYFLOSS },
|
||||
{ "pizza", SHOP_ITEM_PIZZA },
|
||||
{ "popcorn", SHOP_ITEM_POPCORN },
|
||||
{ "hot_dog", SHOP_ITEM_HOT_DOG },
|
||||
{ "tentacle", SHOP_ITEM_TENTACLE },
|
||||
{ "toffee_apple", SHOP_ITEM_TOFFEE_APPLE },
|
||||
{ "doughnut", SHOP_ITEM_DOUGHNUT },
|
||||
{ "chicken", SHOP_ITEM_CHICKEN },
|
||||
{ "pretzel", SHOP_ITEM_PRETZEL },
|
||||
{ "funnel_cake", SHOP_ITEM_FUNNEL_CAKE },
|
||||
{ "beef_noodles", SHOP_ITEM_BEEF_NOODLES },
|
||||
{ "fried_rice_noodles", SHOP_ITEM_FRIED_RICE_NOODLES },
|
||||
{ "wonton_soup", SHOP_ITEM_WONTON_SOUP },
|
||||
{ "meatball_soup", SHOP_ITEM_MEATBALL_SOUP },
|
||||
{ "sub_sandwich", SHOP_ITEM_SUB_SANDWICH },
|
||||
{ "cookie", SHOP_ITEM_COOKIE },
|
||||
{ "roast_sausage", SHOP_ITEM_ROAST_SAUSAGE },
|
||||
{ "drink", SHOP_ITEM_DRINK },
|
||||
{ "coffee", SHOP_ITEM_COFFEE },
|
||||
{ "lemonade", SHOP_ITEM_LEMONADE },
|
||||
{ "chocolate", SHOP_ITEM_CHOCOLATE },
|
||||
{ "iced_tea", SHOP_ITEM_ICED_TEA },
|
||||
{ "fruit_juice", SHOP_ITEM_FRUIT_JUICE },
|
||||
{ "soybean_milk", SHOP_ITEM_SOYBEAN_MILK },
|
||||
{ "sujeonggwa", SHOP_ITEM_SUJEONGGWA },
|
||||
{ "balloon", SHOP_ITEM_BALLOON },
|
||||
{ "toy", SHOP_ITEM_TOY },
|
||||
{ "map", SHOP_ITEM_MAP },
|
||||
{ "photo", SHOP_ITEM_PHOTO },
|
||||
{ "umbrella", SHOP_ITEM_UMBRELLA },
|
||||
{ "voucher", SHOP_ITEM_VOUCHER },
|
||||
{ "hat", SHOP_ITEM_HAT },
|
||||
{ "tshirt", SHOP_ITEM_TSHIRT },
|
||||
{ "sunglasses", SHOP_ITEM_SUNGLASSES },
|
||||
static const std::unordered_map<std::string, ShopItem> LookupTable{
|
||||
{ "burger", ShopItem::Burger },
|
||||
{ "chips", ShopItem::Chips },
|
||||
{ "ice_cream", ShopItem::IceCream },
|
||||
{ "candyfloss", ShopItem::Candyfloss },
|
||||
{ "pizza", ShopItem::Pizza },
|
||||
{ "popcorn", ShopItem::Popcorn },
|
||||
{ "hot_dog", ShopItem::HotDog },
|
||||
{ "tentacle", ShopItem::Tentacle },
|
||||
{ "toffee_apple", ShopItem::ToffeeApple },
|
||||
{ "doughnut", ShopItem::Doughnut },
|
||||
{ "chicken", ShopItem::Chicken },
|
||||
{ "pretzel", ShopItem::Pretzel },
|
||||
{ "funnel_cake", ShopItem::FunnelCake },
|
||||
{ "beef_noodles", ShopItem::BeefNoodles },
|
||||
{ "fried_rice_noodles", ShopItem::FriedRiceNoodles },
|
||||
{ "wonton_soup", ShopItem::WontonSoup },
|
||||
{ "meatball_soup", ShopItem::MeatballSoup },
|
||||
{ "sub_sandwich", ShopItem::SubSandwich },
|
||||
{ "cookie", ShopItem::Cookie },
|
||||
{ "roast_sausage", ShopItem::RoastSausage },
|
||||
{ "drink", ShopItem::Drink },
|
||||
{ "coffee", ShopItem::Coffee },
|
||||
{ "lemonade", ShopItem::Lemonade },
|
||||
{ "chocolate", ShopItem::Chocolate },
|
||||
{ "iced_tea", ShopItem::IcedTea },
|
||||
{ "fruit_juice", ShopItem::FruitJuice },
|
||||
{ "soybean_milk", ShopItem::SoybeanMilk },
|
||||
{ "sujeonggwa", ShopItem::SuJeongGwa },
|
||||
{ "balloon", ShopItem::Balloon },
|
||||
{ "toy", ShopItem::Toy },
|
||||
{ "map", ShopItem::Map },
|
||||
{ "photo", ShopItem::Photo },
|
||||
{ "umbrella", ShopItem::Umbrella },
|
||||
{ "voucher", ShopItem::Voucher },
|
||||
{ "hat", ShopItem::Hat },
|
||||
{ "tshirt", ShopItem::TShirt },
|
||||
{ "sunglasses", ShopItem::Sunglasses },
|
||||
};
|
||||
auto result = LookupTable.find(s);
|
||||
return (result != LookupTable.end()) ? result->second : static_cast<uint8_t>(SHOP_ITEM_NONE);
|
||||
return (result != LookupTable.end()) ? result->second : ShopItem::None;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user