forked from rosebudai/OpenRCT2-Web
This commit is contained in:
1 parent
f67271b57b
commit
6fb525e906
12 files changed
+69
-51
No files matched your search
@@ -514,7 +514,7 @@ namespace OpenRCT2::GameActions
|
||||
continue;
|
||||
|
||||
auto* pathAdditionEntry = path->getAdditionEntry();
|
||||
if (pathAdditionEntry != nullptr && pathAdditionEntry->flags & PATH_ADDITION_FLAG_IS_BIN)
|
||||
if (pathAdditionEntry != nullptr && pathAdditionEntry->flags.has(PathAdditionFlag::isBin))
|
||||
path->setAdditionStatus(0xFF);
|
||||
|
||||
} while (TileElementIteratorNext(&it));
|
||||
|
||||
@@ -100,25 +100,25 @@ namespace OpenRCT2::GameActions
|
||||
LOG_ERROR("Unknown footpath addition entry for entryIndex %d", _entryIndex);
|
||||
return Result(Status::invalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE);
|
||||
}
|
||||
uint16_t sceneryFlags = pathAdditionEntry->flags;
|
||||
PathAdditionFlags sceneryFlags = pathAdditionEntry->flags;
|
||||
|
||||
if ((sceneryFlags & PATH_ADDITION_FLAG_DONT_ALLOW_ON_SLOPE) && pathElement->isSloped())
|
||||
if (sceneryFlags.has(PathAdditionFlag::dontAllowOnSlope) && pathElement->isSloped())
|
||||
{
|
||||
return Result(Status::invalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CANT_BUILD_THIS_ON_SLOPED_FOOTPATH);
|
||||
}
|
||||
|
||||
if ((sceneryFlags & PATH_ADDITION_FLAG_DONT_ALLOW_ON_QUEUE) && pathElement->isQueue())
|
||||
if (sceneryFlags.has(PathAdditionFlag::dontAllowOnQueue) && pathElement->isQueue())
|
||||
{
|
||||
return Result(Status::invalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CANNOT_PLACE_THESE_ON_QUEUE_LINE_AREA);
|
||||
}
|
||||
|
||||
if (!(sceneryFlags & (PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER | PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW))
|
||||
if (!sceneryFlags.hasAny(PathAdditionFlag::jumpingFountainWater, PathAdditionFlag::jumpingFountainSnow)
|
||||
&& (pathElement->getEdges()) == 0x0F)
|
||||
{
|
||||
return Result(Status::invalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_BE_PLACED_ON_PATH_EDGES);
|
||||
}
|
||||
|
||||
if ((sceneryFlags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) && !pathElement->isQueue())
|
||||
if (sceneryFlags.has(PathAdditionFlag::isQueueScreen) && !pathElement->isQueue())
|
||||
{
|
||||
return Result(Status::invalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_PLACE_THESE_ON_QUEUE_AREA);
|
||||
}
|
||||
@@ -180,7 +180,7 @@ namespace OpenRCT2::GameActions
|
||||
|
||||
pathElement->setAdditionEntryIndex(_entryIndex);
|
||||
pathElement->setIsBroken(false);
|
||||
if (pathAdditionEntry->flags & PATH_ADDITION_FLAG_IS_BIN)
|
||||
if (pathAdditionEntry->flags.has(PathAdditionFlag::isBin))
|
||||
{
|
||||
pathElement->setAdditionStatus(255);
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace OpenRCT2::GameActions
|
||||
if (_constructFlags & PathConstructFlag::IsQueue)
|
||||
{
|
||||
// remove any addition that isn't a TV or a lamp
|
||||
if ((elem->flags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) == 0 && (elem->flags & PATH_ADDITION_FLAG_LAMP) == 0)
|
||||
if (!elem->flags.hasAny(PathAdditionFlag::isQueueScreen, PathAdditionFlag::lamp))
|
||||
{
|
||||
pathElement->setIsBroken(false);
|
||||
pathElement->setAddition(0);
|
||||
@@ -267,7 +267,7 @@ namespace OpenRCT2::GameActions
|
||||
else
|
||||
{
|
||||
// remove all TVs
|
||||
if ((elem->flags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN) != 0)
|
||||
if (elem->flags.has(PathAdditionFlag::isQueueScreen))
|
||||
{
|
||||
pathElement->setIsBroken(false);
|
||||
pathElement->setAddition(0);
|
||||
|
||||
@@ -1120,7 +1120,7 @@ namespace OpenRCT2
|
||||
if (pathElement->hasAddition() && !pathElement->additionIsGhost())
|
||||
{
|
||||
auto* pathAddEntry = pathElement->getAdditionEntry();
|
||||
if (pathAddEntry != nullptr && (pathAddEntry->flags & PATH_ADDITION_FLAG_IS_QUEUE_SCREEN))
|
||||
if (pathAddEntry != nullptr && pathAddEntry->flags.has(PathAdditionFlag::isQueueScreen))
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
@@ -2909,8 +2909,8 @@ namespace OpenRCT2
|
||||
if (tileElement->asPath()->additionIsGhost())
|
||||
break;
|
||||
|
||||
if (pathAddEntry->flags
|
||||
& (PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER | PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW))
|
||||
if (pathAddEntry->flags.hasAny(
|
||||
PathAdditionFlag::jumpingFountainWater, PathAdditionFlag::jumpingFountainSnow))
|
||||
{
|
||||
num_fountains++;
|
||||
break;
|
||||
@@ -5556,7 +5556,7 @@ namespace OpenRCT2
|
||||
return;
|
||||
}
|
||||
|
||||
if ((pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BENCH))
|
||||
if (pathAddEntry->flags.has(PathAdditionFlag::isBench))
|
||||
positions_free = 9;
|
||||
}
|
||||
}
|
||||
@@ -5939,7 +5939,7 @@ namespace OpenRCT2
|
||||
break;
|
||||
|
||||
auto* pathAddEntry = pathElement->getAdditionEntry();
|
||||
if (!(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BIN))
|
||||
if (!pathAddEntry->flags.has(PathAdditionFlag::isBin))
|
||||
break;
|
||||
|
||||
if (pathElement->isBroken())
|
||||
@@ -6051,7 +6051,7 @@ namespace OpenRCT2
|
||||
continue;
|
||||
|
||||
auto* pathAddEntry = pathElement->getAdditionEntry();
|
||||
if (pathAddEntry == nullptr || !(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BENCH))
|
||||
if (pathAddEntry == nullptr || !pathAddEntry->flags.has(PathAdditionFlag::isBench))
|
||||
continue;
|
||||
|
||||
if (pathElement->isBroken())
|
||||
@@ -6140,7 +6140,7 @@ namespace OpenRCT2
|
||||
continue;
|
||||
|
||||
auto* pathAddEntry = pathElement->getAdditionEntry();
|
||||
if (pathAddEntry == nullptr || !(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BIN))
|
||||
if (pathAddEntry == nullptr || !pathAddEntry->flags.has(PathAdditionFlag::isBin))
|
||||
continue;
|
||||
|
||||
if (pathElement->isBroken())
|
||||
@@ -6218,7 +6218,7 @@ namespace OpenRCT2
|
||||
continue;
|
||||
|
||||
auto* pathAddEntry = pathElement->getAdditionEntry();
|
||||
if (pathAddEntry == nullptr || !(pathAddEntry->flags & PATH_ADDITION_FLAG_BREAKABLE))
|
||||
if (pathAddEntry == nullptr || !pathAddEntry->flags.has(PathAdditionFlag::breakable))
|
||||
continue;
|
||||
|
||||
if (pathElement->isBroken())
|
||||
|
||||
@@ -252,8 +252,9 @@ namespace OpenRCT2
|
||||
|
||||
bool JumpingFountain::isJumpingFountain(const JumpingFountainType newType, const CoordsXYZ& newLoc)
|
||||
{
|
||||
const int32_t pathAdditionFlagMask = newType == JumpingFountainType::snow ? PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW
|
||||
: PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER;
|
||||
const PathAdditionFlag jumpingFountainFlag = newType == JumpingFountainType::snow
|
||||
? PathAdditionFlag::jumpingFountainSnow
|
||||
: PathAdditionFlag::jumpingFountainWater;
|
||||
|
||||
TileElement* tileElement = MapGetFirstElementAt(newLoc);
|
||||
if (tileElement == nullptr)
|
||||
@@ -270,7 +271,7 @@ namespace OpenRCT2
|
||||
continue;
|
||||
|
||||
auto* pathAdditionEntry = tileElement->asPath()->getAdditionEntry();
|
||||
if (pathAdditionEntry != nullptr && pathAdditionEntry->flags & pathAdditionFlagMask)
|
||||
if (pathAdditionEntry != nullptr && pathAdditionEntry->flags.has(jumpingFountainFlag))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1204,7 +1204,7 @@ namespace OpenRCT2
|
||||
}
|
||||
|
||||
auto* pathAddEntry = tile_element->asPath()->getAdditionEntry();
|
||||
if (!(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BIN) || tile_element->asPath()->isBroken()
|
||||
if (!pathAddEntry->flags.has(PathAdditionFlag::isBin) || tile_element->asPath()->isBroken()
|
||||
|| tile_element->asPath()->additionIsGhost())
|
||||
{
|
||||
stateReset();
|
||||
@@ -1574,7 +1574,7 @@ namespace OpenRCT2
|
||||
if (pathAddEntry == nullptr)
|
||||
return false;
|
||||
|
||||
if (!(pathAddEntry->flags & PATH_ADDITION_FLAG_IS_BIN))
|
||||
if (!pathAddEntry->flags.has(PathAdditionFlag::isBin))
|
||||
return false;
|
||||
|
||||
if (tileElement->asPath()->isBroken())
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "../core/Money.hpp"
|
||||
#include "../localisation/StringIdType.h"
|
||||
#include "../object/PathAdditionFlags.h"
|
||||
#include "ObjectTypes.h"
|
||||
|
||||
enum class CursorID : uint8_t;
|
||||
@@ -25,26 +26,13 @@ namespace OpenRCT2
|
||||
jumpingFountain,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PATH_ADDITION_FLAG_IS_BIN = 1 << 0,
|
||||
PATH_ADDITION_FLAG_IS_BENCH = 1 << 1,
|
||||
PATH_ADDITION_FLAG_BREAKABLE = 1 << 2,
|
||||
PATH_ADDITION_FLAG_LAMP = 1 << 3,
|
||||
PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER = 1 << 4,
|
||||
PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW = 1 << 5,
|
||||
PATH_ADDITION_FLAG_DONT_ALLOW_ON_QUEUE = 1 << 6,
|
||||
PATH_ADDITION_FLAG_DONT_ALLOW_ON_SLOPE = 1 << 7,
|
||||
PATH_ADDITION_FLAG_IS_QUEUE_SCREEN = 1 << 8
|
||||
};
|
||||
|
||||
struct PathAdditionEntry
|
||||
{
|
||||
static constexpr auto kObjectType = ObjectType::pathAdditions;
|
||||
|
||||
StringId name;
|
||||
uint32_t image;
|
||||
uint16_t flags;
|
||||
PathAdditionFlags flags;
|
||||
PathAdditionDrawType draw_type;
|
||||
CursorID tool_id;
|
||||
money64 price;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2026 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../core/FlagHolder.hpp"
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
enum class PathAdditionFlag
|
||||
{
|
||||
isBin = 0,
|
||||
isBench = 1,
|
||||
breakable = 2,
|
||||
lamp = 3,
|
||||
jumpingFountainWater = 4,
|
||||
jumpingFountainSnow = 5,
|
||||
dontAllowOnQueue = 6,
|
||||
dontAllowOnSlope = 7,
|
||||
isQueueScreen = 8
|
||||
};
|
||||
using PathAdditionFlags = FlagHolder<uint16_t, PathAdditionFlag>;
|
||||
} // namespace OpenRCT2
|
||||
@@ -21,7 +21,7 @@ namespace OpenRCT2
|
||||
void PathAdditionObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||
{
|
||||
stream->Seek(6, STREAM_SEEK_CURRENT);
|
||||
_legacyType.flags = stream->ReadValue<uint16_t>();
|
||||
_legacyType.flags = stream->ReadValue<PathAdditionFlags>();
|
||||
_legacyType.draw_type = static_cast<PathAdditionDrawType>(stream->ReadValue<uint8_t>());
|
||||
_legacyType.tool_id = static_cast<CursorID>(stream->ReadValue<uint8_t>());
|
||||
_legacyType.price = stream->ReadValue<money16>();
|
||||
@@ -103,18 +103,18 @@ namespace OpenRCT2
|
||||
SetPrimarySceneryGroup(ObjectEntryDescriptor(Json::GetString(properties["sceneryGroup"])));
|
||||
|
||||
// clang-format off
|
||||
_legacyType.flags = Json::GetFlags<uint16_t>(
|
||||
_legacyType.flags = Json::GetFlagHolder<PathAdditionFlags, PathAdditionFlag>(
|
||||
properties,
|
||||
{
|
||||
{ "isBin", PATH_ADDITION_FLAG_IS_BIN, Json::FlagType::normal },
|
||||
{ "isBench", PATH_ADDITION_FLAG_IS_BENCH, Json::FlagType::normal },
|
||||
{ "isBreakable", PATH_ADDITION_FLAG_BREAKABLE, Json::FlagType::normal },
|
||||
{ "isLamp", PATH_ADDITION_FLAG_LAMP, Json::FlagType::normal },
|
||||
{ "isJumpingFountainWater", PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER, Json::FlagType::normal },
|
||||
{ "isJumpingFountainSnow", PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW, Json::FlagType::normal },
|
||||
{ "isAllowedOnQueue", PATH_ADDITION_FLAG_DONT_ALLOW_ON_QUEUE, Json::FlagType::inverted },
|
||||
{ "isAllowedOnSlope", PATH_ADDITION_FLAG_DONT_ALLOW_ON_SLOPE, Json::FlagType::inverted },
|
||||
{ "isTelevision", PATH_ADDITION_FLAG_IS_QUEUE_SCREEN, Json::FlagType::normal },
|
||||
{ "isBin", PathAdditionFlag::isBin, Json::FlagType::normal },
|
||||
{ "isBench", PathAdditionFlag::isBench, Json::FlagType::normal },
|
||||
{ "isBreakable", PathAdditionFlag::breakable, Json::FlagType::normal },
|
||||
{ "isLamp", PathAdditionFlag::lamp, Json::FlagType::normal },
|
||||
{ "isJumpingFountainWater", PathAdditionFlag::jumpingFountainWater, Json::FlagType::normal },
|
||||
{ "isJumpingFountainSnow", PathAdditionFlag::jumpingFountainSnow, Json::FlagType::normal },
|
||||
{ "isAllowedOnQueue", PathAdditionFlag::dontAllowOnQueue, Json::FlagType::inverted },
|
||||
{ "isAllowedOnSlope", PathAdditionFlag::dontAllowOnSlope, Json::FlagType::inverted },
|
||||
{ "isTelevision", PathAdditionFlag::isQueueScreen, Json::FlagType::normal },
|
||||
});
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ void PaintLampLightEffects(PaintSession& session, const PathElement& pathEl, uin
|
||||
if (pathEl.hasAddition() && !(pathEl.isBroken()))
|
||||
{
|
||||
auto* pathAddEntry = pathEl.getAdditionEntry();
|
||||
if (pathAddEntry != nullptr && pathAddEntry->flags & PATH_ADDITION_FLAG_LAMP)
|
||||
if (pathAddEntry != nullptr && pathAddEntry->flags.has(PathAdditionFlag::lamp))
|
||||
{
|
||||
if (!(pathEl.getEdges() & EDGE_NE))
|
||||
{
|
||||
|
||||
@@ -2092,7 +2092,7 @@ namespace OpenRCT2::Scripting
|
||||
return JS_NULL;
|
||||
|
||||
const auto* additionEntry = el->getAdditionEntry();
|
||||
if (additionEntry == nullptr || !(additionEntry->flags & PATH_ADDITION_FLAG_IS_BIN))
|
||||
if (additionEntry == nullptr || !additionEntry->flags.has(PathAdditionFlag::isBin))
|
||||
return JS_NULL;
|
||||
|
||||
// Each path edge has a 2-bit slot (0 = full, 3 = empty); a bin is only "full" once a
|
||||
|
||||
@@ -145,11 +145,11 @@ void SceneryUpdateTile(const CoordsXY& sceneryPos)
|
||||
auto* pathAddEntry = tileElement->asPath()->getAdditionEntry();
|
||||
if (pathAddEntry != nullptr)
|
||||
{
|
||||
if (pathAddEntry->flags & PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER)
|
||||
if (pathAddEntry->flags.has(PathAdditionFlag::jumpingFountainWater))
|
||||
{
|
||||
JumpingFountain::startAnimation(JumpingFountainType::water, sceneryPos, tileElement);
|
||||
}
|
||||
else if (pathAddEntry->flags & PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW)
|
||||
else if (pathAddEntry->flags.has(PathAdditionFlag::jumpingFountainSnow))
|
||||
{
|
||||
JumpingFountain::startAnimation(JumpingFountainType::snow, sceneryPos, tileElement);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user