Merge branch 'develop'

This commit is contained in:
Tulio Leao committed 2026-11-01 06:38:34 -03:00
commit b0d335bf7e
88 files changed
+889 -675

No files matched your search

+6
View File
@@ -345,6 +345,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v7
- run: git config --global --add safe.directory $PWD
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.21
with:
@@ -490,6 +491,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v7
- run: git config --global --add safe.directory $PWD
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.21
with:
@@ -519,6 +521,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v7
- run: git config --global --add safe.directory $PWD
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.21
with:
@@ -574,6 +577,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v7
- run: git config --global --add safe.directory $PWD
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.21
with:
@@ -590,6 +594,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v7
- run: git config --global --add safe.directory $PWD
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.21
with:
@@ -738,6 +743,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v7
- run: git config --global --add safe.directory $PWD
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.21
with:
+1
View File
@@ -132,6 +132,7 @@ Appreciation for contributors who have provided substantial work, but are no lon
* Ben Spurlock (BenDaSpur) - Plugin API automation helpers
* (frozensnowy) - Draggable path slopes, self-intersecting track designs, refactors, bug fixes, misc.
* Arjan van Dijk (Manticore-007) - Added guests entertained to API.
* Mark Alliban (MarkAlliban) - Added plugin API fields.
## Bug fixes & Refactors
* Claudio Tiecher (janclod)
+20 -2
View File
@@ -2685,8 +2685,8 @@ STR_5582 :Toujours garder le curseur dans la fenêtre
STR_5583 :{COMMA1DP16}m/s
STR_5584 :SI
STR_5585 :Débloque les limites d’exploitation des attractions, permettant par exemple une remontée à {VELOCITY}
STR_5586 :Ouvrir les magasins et boutiques automatiquement
STR_5587 :Ouvre automatiquement les magasins et boutiques après leur construction
STR_5586 :Ouvrir/fermer les magasins et boutiques automatiquement
STR_5587 :Ouvre automatiquement les magasins et boutiques après leur construction, et les ferme automatiquement avant leur démolition
STR_5588 :Jouer avec d’autres joueurs
STR_5589 :Paramètres de notifications
STR_5590 :Prix du parc
@@ -3851,3 +3851,21 @@ STR_7060 :Visiteurs regardant la construction de {STRINGID}
STR_7061 :Visiteurs regardant le décor
STR_7062 :Visiteurs quittant le parc
STR_7063 :Visiteurs regardant la construction d’une nouvelle attraction
STR_7064 :Or
STR_7065 :Ambre
STR_7066 :Améthyste
STR_7067 :Asperge
STR_7068 :Marron
STR_7069 :Rose brûlé
STR_7070 :Cactus
STR_7071 :Caramel
STR_7072 :Cuivre
STR_7073 :Pourpre
STR_7074 :Eau sombre
STR_7075 :Émeraude
STR_7076 :Indigo
STR_7077 :Pesto
STR_7078 :Vert sapin
STR_7079 :Rubis
STR_7080 :Bleu profond
STR_7081 :Argent
+21 -2
View File
@@ -2679,8 +2679,8 @@ STR_5582 :Capturar cursor do rato na xanela
STR_5583  :{COMMA1DP16}m/s
STR_5584 :SI
STR_5585 :Desbloquea os límites de operación da atracción, permitindo cousas como pendentes de elevación a {VELOCITY}
STR_5586 :Abrir tendas e postos automaticamente
STR_5587 :As tendas e os postos abriranse automaticamente despois de seren construidos.
STR_5586 :Abrir e pechar automaticamente as tendas e os postos
STR_5587 :As tendas e os postos abriranse automaticamente despois de construílos e pecharanse automaticamente antes de comezar a construción.
STR_5588 :Xogar con outros xogadores
STR_5589 :Configuración de notificacións
STR_5590 :Premios do parque
@@ -3844,3 +3844,22 @@ STR_7060 :Visitantes mirando a construción de {STRINGID}
STR_7061 :Visitantes mirando a decoración
STR_7062 :Visitantes saíndo do parque
STR_7063 :Visitantes mirando a construción dunha nova atracción
STR_7064 :Dourado
STR_7065 :Ámbar
STR_7066 :Amatista
STR_7067 :Espárrago
STR_7068 :Marrón
STR_7069 :Rosa queimado
STR_7070 :Cacto
STR_7071 :Caramelo
STR_7072 :Cobre
STR_7073 :Carmesí
STR_7074 :Auga escura
STR_7075 :Esmeralda
STR_7076 :Indigo
STR_7077 :Pesto
STR_7078 :Verde piñeiro
STR_7079 :Rubí
STR_7080 :Azul intenso
STR_7081 :Prata
+11
View File
@@ -1,3 +1,14 @@
0.5.7 (in development)
------------------------------------------------------------------------
- Fix: [#16807] Error messages when trying to load regular JSON files as custom objects.
- Fix: [#18954] When researching Classic Mini Roller Coaster vehicles in Bumbly Beach, they all appear as new rides.
- Fix: [#21030, #26981] Slow object loading and index building when using RCT Classic or running from a Flatpak.
- Fix: [#24524] Some build types (like AppImage) lack information about their specific build.
- Fix: [#27264] Headless server crashes when loading a recolourable terrain surface.
- Fix: [#27286] Headless servers no longer write chat logs.
- Fix: [#27300] Walls cannot be placed on every edge of the Reverse Freefall/Air Powered flat to vertical slopes (original bug).
- Fix: [#27316] Height markers are incorrect on diagonal flat to left banked down, large gentle turn left and right banked large gentle turn pieces.
0.5.6 (2026-10-10)
------------------------------------------------------------------------
- Feature: [#16014] Land surfaces and edges can now be recoloured.
+8 -2
View File
@@ -2530,9 +2530,14 @@ declare global {
readonly minLiftHillSpeed: number;
/**
* The satisfaction rating of the ride from 0 to 100.
* The satisfaction rating of the ride from 0 to 100, or NULL if not yet calculated.
*/
readonly satisfaction: number;
readonly satisfaction: number | null;
/**
* The popularity rating of the ride from 0 to 100, or NULL if not calculated.
*/
readonly popularity: number | null;
/**
* The max speed in miles per hour.
@@ -2637,6 +2642,7 @@ declare global {
exit: CoordsXYZD;
/** Queue wait time in minutes for this station. */
readonly queueTime: number;
readonly segmentLength: number;
}
interface TrackSegment {
-6
View File
@@ -31,12 +31,6 @@ using namespace OpenRCT2;
using namespace OpenRCT2::Audio;
using namespace OpenRCT2::Ui;
template<typename T>
static std::shared_ptr<T> ToShared(std::unique_ptr<T>&& src)
{
return std::shared_ptr<T>(std::move(src));
}
/**
* Main entry point for non-Windows systems. Windows instead uses its own DLL proxy.
*/
-3
View File
@@ -245,9 +245,6 @@ namespace OpenRCT2
_chatHistory.push_front(buffer);
_chatHistoryTime.push_front(Platform::GetTicks());
// Log to file (src only as logging does its own timestamp)
Network::AppendChatLog(s);
CreateAudioChannel(SoundId::newsItem, false, kMixerVolumeMax, 0.5f, 1.5f, true);
}
+1 -1
View File
@@ -110,7 +110,7 @@ namespace OpenRCT2::Ui::Windows
widgets[WIDX_PANEL_OUTSET].right = width - 1;
widgets[WIDX_PANEL_INSET].right = width - 3;
bool useFullToolbar = getGameState().park.newsItems.isEmpty()
bool useFullToolbar = getGameState().park.newsItems.queue.empty()
&& (ThemeGetFlags() & UITHEME_FLAG_USE_GAME_STATUS_BAR) && gLegacyScene == LegacyScene::playing;
widgets[WIDX_PANEL_OUTSET].setVisible(useFullToolbar);
+8 -10
View File
@@ -114,7 +114,7 @@ namespace OpenRCT2::Ui::Windows
private:
int32_t _pressedNewsItemIndex{}, _pressedButtonIndex{}, _suspendUpdateTicks{};
WidgetIndex _baseCheckboxIndex{};
News::ItemQueues& _queues;
News::Items& _queues;
static int32_t CalculateNewsItemHeight()
{
@@ -365,12 +365,12 @@ namespace OpenRCT2::Ui::Windows
size_t j = _pressedNewsItemIndex;
_pressedNewsItemIndex = -1;
if (j >= _queues.getArchived().size())
if (j >= _queues.archive.size())
{
return;
}
const auto& newsItem = _queues.getArchived()[j];
const auto& newsItem = _queues.archive[j];
if (newsItem.hasButton())
{
return;
@@ -412,7 +412,7 @@ namespace OpenRCT2::Ui::Windows
ScreenSize onScrollGetSize(int32_t scrollIndex) override
{
int32_t scrollHeight = static_cast<int32_t>(_queues.getArchived().size()) * CalculateNewsItemHeight()
int32_t scrollHeight = static_cast<int32_t>(_queues.archive.size()) * CalculateNewsItemHeight()
- kItemSeparatorHeight;
return { kWindowSize.width, scrollHeight };
}
@@ -423,7 +423,7 @@ namespace OpenRCT2::Ui::Windows
int32_t i = 0;
int32_t buttonIndex = 0;
auto mutableScreenCoords = screenCoords;
for (const auto& newsItem : _queues.getArchived())
for (const auto& newsItem : _queues.archive)
{
if (mutableScreenCoords.y < itemHeight)
{
@@ -470,7 +470,7 @@ namespace OpenRCT2::Ui::Windows
const bool scrollbarVisible = scrolls[0].contentHeight > widgets[WIDX_SCROLL].height() - 1;
const auto scrollbarFill = scrollbarVisible ? 0 : kScrollBarWidth;
for (const auto& newsItem : _queues.getArchived())
for (const auto& newsItem : _queues.archive)
{
if (y >= rt.y + rt.height)
break;
@@ -509,9 +509,8 @@ namespace OpenRCT2::Ui::Windows
auto screenCoords = ScreenCoordsXY{ 328 + scrollbarFill, y + lineHeight + 4 };
auto borderStyle = Rectangle::BorderStyle::outset;
if (_pressedNewsItemIndex != -1)
if (_pressedNewsItemIndex != -1 && _pressedNewsItemIndex < static_cast<int32_t>(_queues.archive.size()))
{
News::IsValidIndex(_pressedNewsItemIndex + News::ItemHistoryStart);
if (i == _pressedNewsItemIndex && _pressedButtonIndex == 1)
{
borderStyle = Rectangle::BorderStyle::inset;
@@ -591,9 +590,8 @@ namespace OpenRCT2::Ui::Windows
auto screenCoords = ScreenCoordsXY{ 352 + scrollbarFill, y + lineHeight + 4 };
auto borderStyle = Rectangle::BorderStyle::outset;
if (_pressedNewsItemIndex != -1)
if (_pressedNewsItemIndex != -1 && _pressedNewsItemIndex < static_cast<int32_t>(_queues.archive.size()))
{
News::IsValidIndex(_pressedNewsItemIndex + News::ItemHistoryStart);
if (i == _pressedNewsItemIndex && _pressedButtonIndex == 2)
borderStyle = Rectangle::BorderStyle::inset;
}
+9 -6
View File
@@ -53,11 +53,11 @@ namespace OpenRCT2::Ui::Windows
class NewsTicker final : public Window
{
private:
News::ItemQueues& _queues;
News::Items& _queues;
void drawNewsItem(RenderTarget& rt)
{
const auto* newsItem = News::GetItem(_queues, 0);
const auto* newsItem = _queues.getActiveMessage();
if (newsItem == nullptr)
return;
@@ -184,14 +184,14 @@ namespace OpenRCT2::Ui::Windows
void onMouseUp(WidgetIndex widgetIndex) override
{
const auto* newsItem = News::GetItem(_queues, 0);
const auto* newsItem = _queues.getActiveMessage();
if (newsItem == nullptr)
return;
switch (widgetIndex)
{
case WIDX_PANEL_INSET:
News::CloseCurrentItem(_queues);
_queues.archiveActiveItem();
break;
case WIDX_NEWS_SUBJECT:
News::OpenSubject(newsItem->type, newsItem->assoc);
@@ -230,7 +230,10 @@ namespace OpenRCT2::Ui::Windows
widgets[WIDX_NEWS_LOCATE].right = width - 6;
widgets[WIDX_NEWS_LOCATE].left = widgets[WIDX_NEWS_LOCATE].right - 24;
auto* newsItem = News::GetItem(_queues, 0);
auto* newsItem = _queues.getActiveMessage();
if (newsItem == nullptr)
return;
setWidgetDisabled(WIDX_NEWS_SUBJECT, false);
setWidgetDisabled(WIDX_NEWS_LOCATE, false);
@@ -265,7 +268,7 @@ namespace OpenRCT2::Ui::Windows
if (currentFrame >= 24)
currentFrame = 0;
if (_queues.isEmpty())
if (_queues.queue.empty())
close();
}
};
+3 -3
View File
@@ -725,7 +725,7 @@ namespace OpenRCT2::Ui::Windows
if (_currentTrackRollEnd != TrackRoll::none || _previousTrackRollEnd != TrackRoll::none)
{
newDisabledWidgets |= (1uLL << WIDX_SLOPE_DOWN_STEEP) | (1uLL << WIDX_SLOPE_UP_STEEP)
| (1uLL << WIDX_CHAIN_LIFT);
| (1uLL << WIDX_CHAIN_LIFT) | (1uLL << WIDX_LEFT_CURVE_VERY_SMALL) | (1uLL << WIDX_RIGHT_CURVE_VERY_SMALL);
}
if (_currentlySelectedTrack != TrackCurve::none)
{
@@ -3467,7 +3467,7 @@ namespace OpenRCT2::Ui::Windows
PathElement* pathsByDir[kNumOrthogonalDirections];
bool keepOrientation = false;
for (int8_t i = 0; i < kNumOrthogonalDirections; i++)
for (Direction i : kAllDirections)
{
const auto testLoc = CoordsXYZ{ *mapCoords + CoordsDirectionDelta[i], z };
if (!MapIsLocationOwned(testLoc))
@@ -3509,7 +3509,7 @@ namespace OpenRCT2::Ui::Windows
if (!keepOrientation)
{
for (int8_t i = 0; i < kNumOrthogonalDirections; i++)
for (Direction i : kAllDirections)
{
if (pathsByDir[i] != nullptr)
{
+1 -1
View File
@@ -32,7 +32,7 @@ static std::vector<std::string> GetCommandLineArgs(int argc, wchar_t** argvW);
/**
* Windows entry point to OpenRCT2 with a console window using a traditional C main function.
*/
int wmain(int argc, wchar_t** argvW, [[maybe_unused]] wchar_t* envp)
int wmain(int argc, wchar_t** argvW)
{
auto argvStrings = GetCommandLineArgs(argc, argvW);
+1 -1
View File
@@ -332,7 +332,7 @@ namespace OpenRCT2
ResearchUpdate();
RideRating::UpdateAll();
RideMeasurementsUpdate();
News::UpdateCurrentItem(park.newsItems);
park.newsItems.updateActiveItem();
MapAnimations::InvalidateAndUpdateAll();
VehicleSoundsUpdate();
+137 -1
View File
@@ -14,10 +14,16 @@
#include "config/Config.h"
#include "core/EnumUtils.hpp"
#include "core/File.h"
#include "core/FileSystem.hpp"
#include "core/Path.hpp"
#include "core/String.hpp"
#include "platform/Platform.h"
#include <map>
#include <mutex>
#include <optional>
#include <unordered_map>
using namespace OpenRCT2;
static constexpr const char* kDirectoryNamesRCT2[] = {
@@ -80,11 +86,124 @@ static constexpr u8string_view kFileNames[] = {
u8"contributors.md", // CONTRIBUTORS
};
/**
* Lower cases ASCII characters only, which matches how String::iequals compares strings.
*/
static u8string toLowerAscii(const u8string_view str)
{
u8string result(str);
for (auto& c : result)
{
c = tolower(c);
}
return result;
}
/**
* Caches the file names of the original game data directories so that they can be looked up case
* insensitively without hitting the file system.
*
* The game refers to the original files by their MS-DOS era upper case names, while an actual
* installation may use any casing, so every look up has to consider all the names in a directory.
* Doing that per look up means listing a directory of a few thousand files hundreds of times while
* loading a park, which is ruinously slow on file systems with a high per-operation cost, such as
* the FUSE file system Flatpak's document portal provides. The original game data does not change
* while the game is running, so each directory only has to be listed once.
*/
class OriginalGameDataIndex
{
private:
struct Entry
{
u8string path;
int32_t depth{};
};
// Maps the lower cased name of a file to the file it was found as.
using Listing = std::unordered_map<u8string, Entry, String::Hash, std::equal_to<>>;
std::mutex _mutex;
std::map<u8string, std::optional<Listing>, std::less<>> _listings;
public:
/**
* Returns the real path of the file with the given name inside the given directory or one of its
* sub directories, matching the name case insensitively. Returns an empty string if there is no
* such file.
*/
u8string findFile(const u8string& directory, u8string_view fileName)
{
std::lock_guard guard(_mutex);
const auto& listing = getListing(directory);
if (!listing.has_value())
{
// The directory could not be listed, fall back to querying the file system.
return Path::ResolveCasing(Path::Combine(directory, fileName));
}
auto it = listing->find(toLowerAscii(fileName));
if (it == listing->end())
return {};
return it->second.path;
}
void clear()
{
std::lock_guard guard(_mutex);
_listings.clear();
}
private:
const std::optional<Listing>& getListing(const u8string& directory)
{
auto it = _listings.find(directory);
if (it != _listings.end())
return it->second;
return _listings.emplace(directory, readListing(directory)).first->second;
}
static std::optional<Listing> readListing(const u8string& directory)
{
std::error_code ec;
auto it = fs::recursive_directory_iterator(fs::u8path(directory), fs::directory_options::skip_permission_denied, ec);
if (ec)
return std::nullopt;
Listing listing;
const auto end = fs::recursive_directory_iterator();
for (; it != end; it.increment(ec))
{
if (ec)
break;
// Asks the directory entry rather than the file system, as the entry already knows the
// type of the file on the platforms that report it while listing a directory.
std::error_code typeEc;
if (it->is_directory(typeEc) || typeEc)
continue;
const auto depth = it.depth();
auto entry = Entry{ it->path().u8string(), depth };
auto [entryIt, inserted] = listing.try_emplace(toLowerAscii(it->path().filename().u8string()), entry);
// Prefer the files closest to the root of the directory, files in sub directories are
// only meant to be used when there is none of that name next to the other game files.
if (!inserted && depth < entryIt->second.depth)
entryIt->second = std::move(entry);
}
return listing;
}
};
class PlatformEnvironment final : public IPlatformEnvironment
{
private:
u8string _basePath[kDirBaseCount];
RCT2Variant _rct2Variant = RCT2Variant::rct2Original;
mutable OriginalGameDataIndex _originalGameDataIndex;
public:
explicit PlatformEnvironment(DirBaseValues basePaths)
@@ -175,7 +294,7 @@ public:
}
}
auto path = Path::ResolveCasing(Path::Combine(dataPath, fileName));
auto path = ResolveOriginalGameDataPath(base, dataPath, fileName);
if (base == DirBase::rct1 && did == DirId::data && !File::Exists(path))
{
// Special case, handle RCT1 steam layout where some data files are under a CD root
@@ -193,6 +312,7 @@ public:
void SetBasePath(DirBase base, u8string_view path) override
{
_basePath[EnumValue(base)] = path;
_originalGameDataIndex.clear();
if (base == DirBase::rct2)
{
@@ -209,6 +329,22 @@ public:
}
private:
/**
* Resolves the casing of a file inside one of the original game data directories, using the
* cached directory listings where possible.
*/
u8string ResolveOriginalGameDataPath(DirBase base, const u8string& dataPath, u8string_view fileName) const
{
const auto isOriginalGameData = base == DirBase::rct1 || base == DirBase::rct2;
const auto isPlainFileName = fileName.find_first_of("/\\") == u8string_view::npos;
if (!isOriginalGameData || !isPlainFileName || dataPath.empty())
{
return Path::ResolveCasing(Path::Combine(dataPath, fileName));
}
return _originalGameDataIndex.findFile(dataPath, fileName);
}
static DirBase GetDefaultBaseDirectory(PathId pathid)
{
switch (pathid)
+4 -4
View File
@@ -344,8 +344,8 @@ namespace OpenRCT2
_currentRecording.reset();
News::Item* news = News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::blank, "Replay recording stopped", 0);
News::Item* news = getGameState().park.newsItems.addItemToQueue(
News::ItemType::blank, "Replay recording stopped", 0);
news->setFlags(News::ItemFlags::hasButton); // Has no subject.
return true;
@@ -471,8 +471,8 @@ namespace OpenRCT2
// During normal playback we pause the game if stopped.
if (_mode == ReplayMode::playing)
{
News::Item* news = News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::blank, "Replay playback complete", 0);
News::Item* news = getGameState().park.newsItems.addItemToQueue(
News::ItemType::blank, "Replay playback complete", 0);
news->setFlags(News::ItemFlags::hasButton); // Has no subject.
}
@@ -88,18 +88,18 @@ 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++)
{
if (index == 1)
{
entranceLoc += CoordsDirectionDelta[(_loc.direction - 1) & 0x3];
entranceLoc += CoordsDirectionDelta[DirectionPrev(_loc.direction)];
}
else if (index == 2)
{
entranceLoc.x += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].x * 2;
entranceLoc.y += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].y * 2;
entranceLoc.x += CoordsDirectionDelta[DirectionNext(_loc.direction)].x * 2;
entranceLoc.y += CoordsDirectionDelta[DirectionNext(_loc.direction)].y * 2;
}
if (auto res2 = MapCanConstructAt({ entranceLoc, zLow, zHigh }, { 0b1111, 0 }); res2.error != Status::ok)
@@ -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(
@@ -143,13 +143,13 @@ namespace OpenRCT2::GameActions
{
if (index == ParkEntranceSequence::left)
{
entranceLoc.x += CoordsDirectionDelta[(_loc.direction - 1) & 0x3].x;
entranceLoc.y += CoordsDirectionDelta[(_loc.direction - 1) & 0x3].y;
entranceLoc.x += CoordsDirectionDelta[DirectionPrev(_loc.direction)].x;
entranceLoc.y += CoordsDirectionDelta[DirectionPrev(_loc.direction)].y;
}
else if (index == ParkEntranceSequence::right)
{
entranceLoc.x += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].x * 2;
entranceLoc.y += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].y * 2;
entranceLoc.x += CoordsDirectionDelta[DirectionNext(_loc.direction)].x * 2;
entranceLoc.y += CoordsDirectionDelta[DirectionNext(_loc.direction)].y * 2;
}
if (!flags.has(CommandFlag::ghost))
@@ -208,12 +208,12 @@ namespace OpenRCT2::GameActions
{
if (index == 1)
{
entranceLoc += CoordsDirectionDelta[(_loc.direction - 1) & 0x3];
entranceLoc += CoordsDirectionDelta[DirectionPrev(_loc.direction)];
}
else if (index == 2)
{
entranceLoc.x += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].x * 2;
entranceLoc.y += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].y * 2;
entranceLoc.x += CoordsDirectionDelta[DirectionNext(_loc.direction)].x * 2;
entranceLoc.y += CoordsDirectionDelta[DirectionNext(_loc.direction)].y * 2;
}
if (!MapCheckCapacityAndReorganise(entranceLoc, numTiles))
{
@@ -80,7 +80,7 @@ namespace OpenRCT2::GameActions
return Result(Status::invalidParameters, STR_CANT_REMOVE_THIS, kStringIdNone);
}
auto direction = (park.entrances[entranceIndex].direction - 1) & 3;
auto direction = DirectionPrev(park.entrances[entranceIndex].direction);
// Centre (sign)
ParkEntranceRemoveSegment(_loc);
@@ -279,11 +279,7 @@ namespace OpenRCT2::GameActions
{
auto rand = ScenarioRandMax(static_cast<uint32_t>(park.entrances.size()));
const auto& entrance = park.entrances[rand];
auto dir = entrance.direction;
newLocation = entrance;
// TODO: Replace with CoordsDirectionDelta
newLocation.x += 16 + ((dir & 1) == 0 ? ((dir & 2) ? 32 : -32) : 0);
newLocation.y += 16 + ((dir & 1) == 1 ? ((dir & 2) ? -32 : 32) : 0);
newLocation = entrance + CoordsDirectionDelta[entrance.direction] + CoordsXY{ 16, 16 };
}
else
{
@@ -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);
}
@@ -513,7 +513,7 @@ namespace OpenRCT2::GameActions
continue;
if (elementType == TileElementType::wall)
{
int32_t direction = tileElement->getDirection();
Direction direction = tileElement->getDirection();
if (_edge == direction)
{
auto res = Result(Status::noClearance, STR_CANT_BUILD_THIS_HERE, kStringIdNone);
@@ -513,7 +513,7 @@ namespace OpenRCT2::GameActions
uint8_t intersectingDirections = ted.sequenceData.sequences[blockIndex].allowedWallEdges;
intersectingDirections ^= 0x0F;
intersectingDirections = rol4(intersectingDirections, _origin.direction);
for (int32_t i = 0; i < kNumOrthogonalDirections; i++)
for (Direction i : kAllDirections)
{
if (intersectingDirections & (1 << i))
{
+32 -13
View File
@@ -24,6 +24,7 @@
#include "String.hpp"
#include <memory>
#include <optional>
#include <set>
#include <stack>
#include <string>
@@ -148,17 +149,8 @@ public:
virtual void getDirectoryChildren(std::vector<DirectoryChild>& children, const std::string& path) = 0;
private:
void pushState(const std::string& directory)
{
DirectoryState newState;
newState.path = directory;
newState.index = -1;
getDirectoryChildren(newState.listing, directory);
_directoryStack.push(newState);
}
bool patternMatch(const std::string& fileName)
protected:
bool patternMatch(const std::string& fileName) const
{
for (const auto& pattern : _patterns)
{
@@ -170,6 +162,16 @@ private:
return false;
}
private:
void pushState(const std::string& directory)
{
DirectoryState newState;
newState.path = directory;
newState.index = -1;
getDirectoryChildren(newState.listing, directory);
_directoryStack.push(newState);
}
static std::vector<std::string> getPatterns(const std::string& delimitedPatterns)
{
std::vector<std::string> patterns;
@@ -328,7 +330,11 @@ public:
const struct dirent* node = namelist[i];
if (!String::equals(node->d_name, ".") && !String::equals(node->d_name, ".."))
{
children.push_back(createChild(path.c_str(), node));
auto child = createChild(path.c_str(), node);
if (child.has_value())
{
children.push_back(std::move(child.value()));
}
}
free(namelist[i]);
}
@@ -342,7 +348,7 @@ private:
return 1;
}
static DirectoryChild createChild(const utf8* directory, const struct dirent* node)
std::optional<DirectoryChild> createChild(const utf8* directory, const struct dirent* node) const
{
DirectoryChild result;
result.name = std::string(node->d_name);
@@ -358,6 +364,19 @@ private:
}
else
{
#ifndef __HAIKU__
// Reading the size and modified time of a file costs a stat call each, which is
// expensive on file systems with a high per-operation cost, such as network shares or
// the FUSE file system that Flatpak's document portal provides. Files that cannot match
// the search pattern are never returned, so skip them before paying for that. Entries of
// an unknown type still have to be queried to find out whether they are a directory
// which has to be recursed into.
if (node->d_type == DT_REG && !patternMatch(result.name))
{
return std::nullopt;
}
#endif
result.type = DirectoryChildType::file;
// Get the full path of the file
+11 -11
View File
@@ -53,13 +53,13 @@ struct ttf_getwidth_cache_entry
static ttf_cache_entry _ttfSurfaceCache[kTTFSurfaceCacheSize] = {};
static int32_t _ttfSurfaceCacheCount = 0;
static int32_t _ttfSurfaceCacheHitCount = 0;
static int32_t _ttfSurfaceCacheMissCount = 0;
// static int32_t _ttfSurfaceCacheHitCount = 0;
// static int32_t _ttfSurfaceCacheMissCount = 0;
static ttf_getwidth_cache_entry _ttfGetWidthCache[kTTFGetWidthCacheSize] = {};
static int32_t _ttfGetWidthCacheCount = 0;
static int32_t _ttfGetWidthCacheHitCount = 0;
static int32_t _ttfGetWidthCacheMissCount = 0;
// static int32_t _ttfGetWidthCacheCount = 0;
// static int32_t _ttfGetWidthCacheHitCount = 0;
// static int32_t _ttfGetWidthCacheMissCount = 0;
static std::mutex _mutex;
@@ -220,7 +220,7 @@ TTFSurface* TTFSurfaceCacheGetOrAdd(TTF_Font* font, std::string_view text)
break;
if (entry->font == font && String::equals(entry->text, text))
{
_ttfSurfaceCacheHitCount++;
// _ttfSurfaceCacheHitCount++;
entry->lastUseTick = gCurrentDrawCount;
return entry->surface;
}
@@ -246,7 +246,7 @@ TTFSurface* TTFSurfaceCacheGetOrAdd(TTF_Font* font, std::string_view text)
return nullptr;
}
_ttfSurfaceCacheMissCount++;
// _ttfSurfaceCacheMissCount++;
// printf("CACHE HITS: %d MISSES: %d)\n", _ttfSurfaceCacheHitCount, _ttfSurfaceCacheMissCount);
_ttfSurfaceCacheCount++;
@@ -272,7 +272,7 @@ static void TTFGetWidthCacheDisposeAll()
for (int32_t i = 0; i < kTTFGetWidthCacheSize; i++)
{
TTFGetWidthCacheDispose(&_ttfGetWidthCache[i]);
_ttfGetWidthCacheCount--;
// _ttfGetWidthCacheCount--;
}
}
@@ -294,7 +294,7 @@ uint32_t TTFGetWidthCacheGetOrAdd(TTF_Font* font, std::string_view text)
break;
if (entry->font == font && String::equals(entry->text, text))
{
_ttfGetWidthCacheHitCount++;
// _ttfGetWidthCacheHitCount++;
entry->lastUseTick = gCurrentDrawCount;
return entry->width;
}
@@ -317,9 +317,9 @@ uint32_t TTFGetWidthCacheGetOrAdd(TTF_Font* font, std::string_view text)
int32_t width, height;
TTFGetSize(font, text, &width, &height);
_ttfGetWidthCacheMissCount++;
// _ttfGetWidthCacheMissCount++;
_ttfGetWidthCacheCount++;
// _ttfGetWidthCacheCount++;
entry->width = width;
entry->font = font;
entry->text = text;
+8 -10
View File
@@ -1619,9 +1619,8 @@ namespace OpenRCT2
ft.Add<StringId>(shopItemDescriptor.Naming.Indefinite);
if (Config::Get().notifications.guestBoughtItem)
{
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::peepOnRide, STR_PEEP_TRACKING_NOTIFICATION_BOUGHT_X,
guest.id, ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::peepOnRide, STR_PEEP_TRACKING_NOTIFICATION_BOUGHT_X, guest.id, ft);
}
}
@@ -3553,9 +3552,8 @@ namespace OpenRCT2
ride.formatNameTo(ft);
if (Config::Get().notifications.rideWarnings)
{
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::ride, STR_GUESTS_GETTING_STUCK_ON_RIDE,
guest.currentRide.ToUnderlying(), ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::ride, STR_GUESTS_GETTING_STUCK_ON_RIDE, guest.currentRide.ToUnderlying(), ft);
}
}
}
@@ -3860,7 +3858,7 @@ namespace OpenRCT2
if (Config::Get().notifications.guestOnRide)
{
News::AddItemToQueue(getGameState().park.newsItems, News::ItemType::peepOnRide, msg_string, id, ft);
getGameState().park.newsItems.addItemToQueue(News::ItemType::peepOnRide, msg_string, id, ft);
}
}
@@ -4908,7 +4906,7 @@ namespace OpenRCT2
uint8_t hedges[4]{ 0xFF, 0xFF, 0xFF, 0xFF };
uint8_t openCount = 0;
uint8_t mazeReverseLastEdge = DirectionReverse(mazeLastEdge);
for (uint8_t i = 0; i < kNumOrthogonalDirections; ++i)
for (Direction i : kAllDirections)
{
if (!(mazeEntry & (1 << kMazeCurrentDirectionToOpenHedge[var37 / 4][i])) && i != mazeReverseLastEdge)
{
@@ -5019,8 +5017,8 @@ namespace OpenRCT2
if (Config::Get().notifications.guestLeftRide)
{
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::peepOnRide, STR_PEEP_TRACKING_LEFT_RIDE_X, id, ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::peepOnRide, STR_PEEP_TRACKING_LEFT_RIDE_X, id, ft);
}
}
}
+1 -1
View File
@@ -98,7 +98,7 @@ namespace OpenRCT2
{
case Pattern::cyclicSquares:
// 0, 1, 2, 3
for (int32_t i = 0; i < kNumOrthogonalDirections; i++)
for (Direction i : kAllDirections)
{
create(
newType, { newLoc + _fountainDirectionsPositive[i], newZ }, _fountainDirections[i],
+18 -24
View File
@@ -71,7 +71,6 @@ namespace OpenRCT2
using namespace OpenRCT2::Drawing;
static uint8_t _backupAnimationImageIdOffset;
static TileElement* _peepRideEntranceExitElement;
static std::shared_ptr<IAudioChannel> _crowdSoundChannel = nullptr;
@@ -787,7 +786,7 @@ namespace OpenRCT2
{
auto ft = Formatter();
formatNameTo(ft);
News::AddItemToQueue(park.newsItems, News::ItemType::blank, STR_NEWS_ITEM_GUEST_DROWNED, x | (y << 16), ft);
park.newsItems.addItemToQueue(News::ItemType::blank, STR_NEWS_ITEM_GUEST_DROWNED, x | (y << 16), ft);
}
park.ratingCasualtyPenalty = std::min(park.ratingCasualtyPenalty + 25, 1000);
@@ -1049,7 +1048,7 @@ namespace OpenRCT2
if (Config::Get().notifications.guestWarnings)
{
constexpr auto kThoughtId = static_cast<uint32_t>(PeepThoughtType::hungry);
News::AddItemToQueue(newsItems, News::ItemType::peeps, STR_PEEPS_ARE_HUNGRY, kThoughtId, {});
newsItems.addItemToQueue(News::ItemType::peeps, STR_PEEPS_ARE_HUNGRY, kThoughtId, {});
}
}
@@ -1061,7 +1060,7 @@ namespace OpenRCT2
if (Config::Get().notifications.guestWarnings)
{
constexpr auto kThoughtId = static_cast<uint32_t>(PeepThoughtType::thirsty);
News::AddItemToQueue(newsItems, News::ItemType::peeps, STR_PEEPS_ARE_THIRSTY, kThoughtId, {});
newsItems.addItemToQueue(News::ItemType::peeps, STR_PEEPS_ARE_THIRSTY, kThoughtId, {});
}
}
@@ -1073,7 +1072,7 @@ namespace OpenRCT2
if (Config::Get().notifications.guestWarnings)
{
constexpr auto kThoughtId = static_cast<uint32_t>(PeepThoughtType::toilet);
News::AddItemToQueue(newsItems, News::ItemType::peeps, STR_PEEPS_CANT_FIND_TOILET, kThoughtId, {});
newsItems.addItemToQueue(News::ItemType::peeps, STR_PEEPS_CANT_FIND_TOILET, kThoughtId, {});
}
}
@@ -1085,7 +1084,7 @@ namespace OpenRCT2
if (Config::Get().notifications.guestWarnings)
{
constexpr auto kThoughtId = static_cast<uint32_t>(PeepThoughtType::badLitter);
News::AddItemToQueue(newsItems, News::ItemType::peeps, STR_PEEPS_DISLIKE_LITTER, kThoughtId, {});
newsItems.addItemToQueue(News::ItemType::peeps, STR_PEEPS_DISLIKE_LITTER, kThoughtId, {});
}
}
@@ -1097,7 +1096,7 @@ namespace OpenRCT2
if (Config::Get().notifications.guestWarnings)
{
constexpr auto kThoughtId = static_cast<uint32_t>(PeepThoughtType::pathDisgusting);
News::AddItemToQueue(newsItems, News::ItemType::peeps, STR_PEEPS_DISGUSTED_BY_PATHS, kThoughtId, {});
newsItems.addItemToQueue(News::ItemType::peeps, STR_PEEPS_DISGUSTED_BY_PATHS, kThoughtId, {});
}
}
@@ -1109,7 +1108,7 @@ namespace OpenRCT2
if (Config::Get().notifications.guestWarnings)
{
constexpr auto kThoughtId = static_cast<uint32_t>(PeepThoughtType::vandalism);
News::AddItemToQueue(newsItems, News::ItemType::peeps, STR_PEEPS_DISLIKE_VANDALISM, kThoughtId, {});
newsItems.addItemToQueue(News::ItemType::peeps, STR_PEEPS_DISLIKE_VANDALISM, kThoughtId, {});
}
}
@@ -1121,7 +1120,7 @@ namespace OpenRCT2
if (Config::Get().notifications.guestWarnings)
{
constexpr auto kThoughtId = static_cast<uint32_t>(PeepThoughtType::cantFindExit);
News::AddItemToQueue(newsItems, News::ItemType::peeps, STR_PEEPS_GETTING_LOST_OR_STUCK, kThoughtId, {});
newsItems.addItemToQueue(News::ItemType::peeps, STR_PEEPS_GETTING_LOST_OR_STUCK, kThoughtId, {});
}
}
else if (lostCounter >= kPeepLostWarningThreshold)
@@ -1130,7 +1129,7 @@ namespace OpenRCT2
if (Config::Get().notifications.guestWarnings)
{
constexpr auto kThoughtId = static_cast<uint32_t>(PeepThoughtType::lost);
News::AddItemToQueue(newsItems, News::ItemType::peeps, STR_PEEPS_GETTING_LOST_OR_STUCK, kThoughtId, {});
newsItems.addItemToQueue(News::ItemType::peeps, STR_PEEPS_GETTING_LOST_OR_STUCK, kThoughtId, {});
}
}
@@ -1146,8 +1145,8 @@ namespace OpenRCT2
queueComplainingGuestsMap.begin(), queueComplainingGuestsMap.end(),
[](auto& lhs, auto& rhs) { return lhs.second < rhs.second; });
auto rideId = rideWithMostQueueComplaints->first.ToUnderlying();
News::AddItemToQueue(
newsItems, News::ItemType::ride, STR_PEEPS_COMPLAINING_ABOUT_QUEUE_LENGTH_WARNING, rideId, {});
newsItems.addItemToQueue(News::ItemType::ride, STR_PEEPS_COMPLAINING_ABOUT_QUEUE_LENGTH_WARNING, rideId, {});
}
}
}
@@ -1563,12 +1562,10 @@ namespace OpenRCT2
if (entranceType == EntranceType::rideExit)
{
pathing_result |= PATHING_RIDE_EXIT;
_peepRideEntranceExitElement = tile_element;
}
else if (entranceType == EntranceType::rideEntrance)
{
pathing_result |= PATHING_RIDE_ENTRANCE;
_peepRideEntranceExitElement = tile_element;
}
if (entranceType == EntranceType::rideExit)
@@ -1652,9 +1649,8 @@ namespace OpenRCT2
ride->formatNameTo(ft);
if (Config::Get().notifications.guestQueuingForRide)
{
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::peepOnRide, STR_PEEP_TRACKING_PEEP_JOINED_QUEUE_FOR_X,
guest->id, ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::peepOnRide, STR_PEEP_TRACKING_PEEP_JOINED_QUEUE_FOR_X, guest->id, ft);
}
}
}
@@ -1714,9 +1710,8 @@ namespace OpenRCT2
guest->formatNameTo(ft);
if (Config::Get().notifications.guestLeftPark)
{
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::peepOnRide, STR_PEEP_TRACKING_LEFT_PARK, guest->id,
ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::peepOnRide, STR_PEEP_TRACKING_LEFT_PARK, guest->id, ft);
}
}
return true;
@@ -2108,9 +2103,8 @@ namespace OpenRCT2
ride->formatNameTo(ft);
if (Config::Get().notifications.guestQueuingForRide)
{
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::peepOnRide,
STR_PEEP_TRACKING_PEEP_JOINED_QUEUE_FOR_X, guest->id, ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::peepOnRide, STR_PEEP_TRACKING_PEEP_JOINED_QUEUE_FOR_X, guest->id, ft);
}
}
@@ -2228,7 +2222,7 @@ namespace OpenRCT2
: STR_PEEP_TRACKING_PEEP_IS_ON_X;
if (Config::Get().notifications.guestUsedFacility)
{
News::AddItemToQueue(getGameState().park.newsItems, News::ItemType::peepOnRide, string_id, guest->id, ft);
getGameState().park.newsItems.addItemToQueue(News::ItemType::peepOnRide, string_id, guest->id, ft);
}
}
}
@@ -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)");
@@ -1663,7 +1663,7 @@ static void ConsoleCommandAddNewsItem([[maybe_unused]] InteractiveConsole& conso
}
}
News::AddItemToQueue(getGameState().park.newsItems, itemType, msg, assoc);
getGameState().park.newsItems.addItemToQueue(itemType, msg, assoc);
console.WriteLine("Successfully added News Item");
}
+1
View File
@@ -1000,6 +1000,7 @@
<ClCompile Include="object\LargeSceneryObject.cpp" />
<ClCompile Include="object\MusicObject.cpp" />
<ClCompile Include="object\Object.cpp" />
<ClCompile Include="object\ObjectAsset.cpp" />
<ClCompile Include="object\ObjectEntryManager.cpp" />
<ClCompile Include="object\ObjectFactory.cpp" />
<ClCompile Include="object\ObjectList.cpp" />
+1 -1
View File
@@ -624,7 +624,7 @@ static void AwardAdd(AwardType type)
park.currentAwards.push_back(Award{ 5u, type });
if (Config::Get().notifications.parkAward)
{
News::AddItemToQueue(park.newsItems, News::ItemType::award, AwardGetNews(type), 0, {});
park.newsItems.addItemToQueue(News::ItemType::award, AwardGetNews(type), 0, {});
}
Ui::GetWindowManager()->InvalidateByClass(WindowClass::parkInformation);
}
+2 -2
View File
@@ -100,8 +100,8 @@ static void MarketingRaiseFinishedNotification(const MarketingCampaign& campaign
ft.Add<StringId>(GetShopItemDescriptor(campaign.shopItemType).Naming.Plural);
}
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::campaign, kMarketingCampaignNames[campaign.type][2], 0, ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::campaign, kMarketingCampaignNames[campaign.type][2], 0, ft);
}
}
+42 -146
View File
@@ -32,78 +32,20 @@
using namespace OpenRCT2;
News::Item& News::ItemQueues::current()
{
return _recent.front();
}
const News::Item& News::ItemQueues::current() const
{
return _recent.front();
}
bool News::IsValidIndex(int32_t index)
{
if (index >= MaxItems)
{
LOG_ERROR("Tried to get news item past MAX_NEWS.");
return false;
}
return true;
}
News::Item* News::GetItem(ItemQueues& queues, int32_t index)
{
return queues.at(index);
}
News::Item& News::ItemQueues::operator[](size_t index)
{
return const_cast<Item&>(const_cast<const ItemQueues&>(*this)[index]);
}
const News::Item& News::ItemQueues::operator[](size_t index) const
{
if (index < _recent.capacity())
return _recent[index];
return _archived[index - _recent.capacity()];
}
News::Item* News::ItemQueues::at(int32_t index)
{
return const_cast<Item*>(const_cast<const ItemQueues&>(*this).at(index));
}
const News::Item* News::ItemQueues::at(int32_t index) const
{
if (IsValidIndex(index))
{
return &(*this)[index];
}
return nullptr;
}
bool News::ItemQueues::isEmpty() const
{
return _recent.empty();
}
/**
*
* rct2: 0x0066DF32
*/
void News::ItemQueues::clear()
void News::Items::clear()
{
_recent.clear();
_archived.clear();
queue.clear();
archive.clear();
}
void News::InitQueue(Park::ParkData& park)
{
park.newsItems.clear();
assert(park.newsItems.isEmpty());
assert(park.newsItems.archive.empty() && park.newsItems.queue.empty());
// Throttles for warning types (PEEP_*_WARNING)
for (auto& warningThrottle : park.peepWarningThrottle)
@@ -115,14 +57,9 @@ void News::InitQueue(Park::ParkData& park)
ContextBroadcastIntent(&intent);
}
uint16_t News::ItemQueues::incrementTicks()
void News::Items::tickActiveItem()
{
return ++current().ticks;
}
static void TickCurrent(News::ItemQueues& queues)
{
int32_t ticks = queues.incrementTicks();
int32_t ticks = ++queue.front().ticks;
// Only play news item sound when in normal playing mode
if (ticks == 1 && (gLegacyScene == LegacyScene::playing))
{
@@ -131,66 +68,57 @@ static void TickCurrent(News::ItemQueues& queues)
}
}
int32_t News::ItemQueues::removeTime() const
int32_t News::Items::removeTime() const
{
if (!_recent[5].isEmpty() && !_recent[4].isEmpty() && !_recent[3].isEmpty() && !_recent[2].isEmpty())
if (!queue[5].isEmpty() && !queue[4].isEmpty() && !queue[3].isEmpty() && !queue[2].isEmpty())
{
return 256;
}
return 320;
}
bool News::ItemQueues::currentShouldBeArchived() const
bool News::Items::activeItemShouldBeArchived() const
{
return current().ticks >= removeTime();
return queue.front().ticks >= removeTime();
}
/**
*
* rct2: 0x0066E252
*/
void News::UpdateCurrentItem(ItemQueues& queues)
void News::Items::updateActiveItem()
{
PROFILED_FUNCTION();
// Check if there is a current news item
if (queues.isEmpty())
if (queue.empty())
return;
auto intent = Intent(INTENT_ACTION_UPDATE_NEWS_TICKER);
ContextBroadcastIntent(&intent);
// Update the current news item
TickCurrent(queues);
tickActiveItem();
// Removal of current news item
if (queues.currentShouldBeArchived())
queues.archiveCurrent();
if (activeItemShouldBeArchived())
archiveActiveItem();
}
/**
*
* rct2: 0x0066E377
*/
void News::CloseCurrentItem(ItemQueues& queues)
{
queues.archiveCurrent();
}
void News::ItemQueues::archiveCurrent()
void News::Items::archiveActiveItem()
{
// Check if there is a current message
if (isEmpty())
if (queue.empty())
return;
_archived.push_back(current());
archive.push_back(queue.front());
// Invalidate the news window
auto* windowMgr = Ui::GetWindowManager();
windowMgr->InvalidateByClass(WindowClass::recentNews);
// Dequeue the current news item, shift news up
_recent.pop_front();
queue.pop_front();
// Invalidate current news item bar
auto intent = Intent(INTENT_ACTION_UPDATE_NEWS_TICKER);
@@ -285,47 +213,50 @@ std::optional<CoordsXYZ> News::GetSubjectLocation(ItemType type, int32_t subject
return subjectLoc;
}
News::Item* News::ItemQueues::firstOpenOrNewSlot()
News::Item* News::Items::firstOpenOrNewSlot()
{
for (auto emptySlots = _recent.capacity() - _recent.size(); emptySlots < 2; ++emptySlots)
for (auto emptySlots = queue.capacity() - queue.size(); emptySlots < 2; ++emptySlots)
{
archiveCurrent();
archiveActiveItem();
}
auto res = _recent.end();
auto res = queue.end();
// The for loop above guarantees there is always an extra element to use
assert(_recent.capacity() - _recent.size() >= 2);
assert(queue.capacity() - queue.size() >= 2);
auto newsItem = res + 1;
newsItem->type = ItemType::null;
return &*res;
}
const News::Item* News::Items::getActiveMessage() const
{
return queue.at(0);
}
/**
*
* rct2: 0x0066DF55
*/
News::Item* News::AddItemToQueue(
ItemQueues& queues, ItemType type, StringId string_id, uint32_t assoc, const Formatter& formatter)
News::Item* News::Items::addItemToQueue(ItemType type, StringId string_id, uint32_t assoc, const Formatter& formatter)
{
utf8 buffer[256];
// overflows possible?
FormatStringLegacy(buffer, 256, string_id, formatter.Data());
return AddItemToQueue(queues, type, buffer, assoc);
return addItemToQueue(type, buffer, assoc);
}
// TODO: Use variant for assoc, requires strong type for each possible input.
News::Item* News::AddItemToQueue(
ItemQueues& queues, ItemType type, StringId string_id, EntityId assoc, const Formatter& formatter)
News::Item* News::Items::addItemToQueue(ItemType type, StringId string_id, EntityId assoc, const Formatter& formatter)
{
return AddItemToQueue(queues, type, string_id, assoc.ToUnderlying(), formatter);
return addItemToQueue(type, string_id, assoc.ToUnderlying(), formatter);
}
News::Item* News::AddItemToQueue(ItemQueues& queues, ItemType type, const utf8* text, uint32_t assoc)
News::Item* News::Items::addItemToQueue(ItemType type, const utf8* text, uint32_t assoc)
{
auto& date = GetDate();
Item* newsItem = queues.firstOpenOrNewSlot();
Item* newsItem = firstOpenOrNewSlot();
newsItem->type = type;
newsItem->flags = 0;
newsItem->assoc = assoc; // Make optional for Award, Money, Graph and Null
@@ -433,64 +364,29 @@ void News::OpenSubject(ItemType type, int32_t subject)
*
* rct2: 0x0066E407
*/
void News::DisableNewsItems(ItemQueues& queues, ItemType type, uint32_t assoc)
void News::DisableNewsItems(Items& newsItems, ItemType type, uint32_t assoc)
{
// TODO: write test invalidating windows
queues.foreachRecentNews([type, assoc, &queues](auto& newsItem) {
for (auto& newsItem : newsItems.queue)
{
if (type == newsItem.type && assoc == newsItem.assoc)
{
newsItem.setFlags(ItemFlags::hasButton);
if (&newsItem == &queues.current())
if (&newsItem == &newsItems.queue.front())
{
auto intent = Intent(INTENT_ACTION_UPDATE_NEWS_TICKER);
ContextBroadcastIntent(&intent);
}
}
});
}
queues.foreachArchivedNews([type, assoc](auto& newsItem) {
for (auto& newsItem : newsItems.archive)
{
if (type == newsItem.type && assoc == newsItem.assoc)
{
newsItem.setFlags(ItemFlags::hasButton);
auto* windowMgr = Ui::GetWindowManager();
windowMgr->InvalidateByClass(WindowClass::recentNews);
}
});
}
void News::AddItemToQueue(ItemQueues& queues, Item* newNewsItem)
{
Item* newsItem = queues.firstOpenOrNewSlot();
*newsItem = *newNewsItem;
}
void News::RemoveItem(ItemQueues& queues, int32_t index)
{
if (index < 0 || index >= MaxItems)
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;
for (size_t i = index; i < newsBoundary - 1; i++)
{
queues[i] = queues[i + 1];
}
queues[newsBoundary - 1].type = ItemType::null;
}
void News::importNewsItems(ItemQueues& queues, const std::span<const Item> recent, const std::span<const Item> archived)
{
queues.clear();
for (size_t i = 0; i < std::min<size_t>(recent.size(), ItemHistoryStart); i++)
{
queues[i] = recent[i];
}
for (size_t i = 0; i < std::min<size_t>(archived.size(), MaxItemsArchive); i++)
{
queues[ItemHistoryStart + i] = archived[i];
}
}
+54 -61
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,12 +126,11 @@ namespace OpenRCT2::News
}
};
constexpr int32_t ItemHistoryStart = 11;
constexpr int32_t MaxItemsArchive = 50;
constexpr int32_t MaxItems = ItemHistoryStart + MaxItemsArchive;
constexpr int32_t kNewsQueueSize = 11;
constexpr int32_t kNewsArchiveSize = 50;
template<std::size_t N>
class ItemQueue
class ItemCollection
{
public:
static_assert(N > 0, "Cannot instantiate News::ItemQueue with size=0");
@@ -148,7 +147,7 @@ namespace OpenRCT2::News
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
ItemQueue()
ItemCollection()
{
std::get<0>(_queue).type = ItemType::null;
}
@@ -248,81 +247,75 @@ namespace OpenRCT2::News
std::fill(_queue.begin(), _queue.end(), Item{});
}
const_pointer at(int32_t index) const
{
if (_queue[index].type == ItemType::null)
return nullptr;
return &_queue[index];
}
void remove(int32_t index)
{
// News item is already null, no need to remove it
if (_queue[index].type == ItemType::null)
return;
for (size_t i = index; i < N - 1; i++)
{
_queue[i] = _queue[i + 1];
}
_queue[N - 1].type = ItemType::null;
}
void importQueue(const std::span<const value_type> src)
{
clear();
for (size_t i = 0; i < std::min<size_t>(src.size(), N); i++)
{
_queue[i] = src[i];
}
}
private:
std::array<Item, N> _queue;
};
struct ItemQueues
using NewsArchive = ItemCollection<kNewsArchiveSize>;
using NewsQueue = ItemCollection<kNewsQueueSize>;
struct Items
{
Item& operator[](size_t index);
const Item& operator[](size_t index) const;
Item* at(int32_t index);
const Item* at(int32_t index) const;
bool isEmpty() const;
NewsQueue queue;
NewsArchive archive;
void clear();
uint16_t incrementTicks();
Item& current();
const Item& current() const;
bool currentShouldBeArchived() const;
void archiveCurrent();
Item* firstOpenOrNewSlot();
const auto& getRecent() const
{
return _recent;
}
const auto& getArchived() const
{
return _archived;
}
template<typename Predicate>
void foreachRecentNews(Predicate&& p)
{
for (auto& newsItem : _recent)
{
p(newsItem);
}
}
void updateActiveItem();
void archiveActiveItem();
template<typename Predicate>
void foreachArchivedNews(Predicate&& p)
{
for (auto& newsItem : _archived)
{
p(newsItem);
}
}
const Item* getActiveMessage() const;
Item* addItemToQueue(ItemType type, StringId string_id, uint32_t assoc, const Formatter& formatter);
Item* addItemToQueue(ItemType type, StringId string_id, EntityId assoc, const Formatter& formatter);
Item* addItemToQueue(ItemType type, const utf8* text, uint32_t assoc);
private:
Item* firstOpenOrNewSlot();
int32_t removeTime() const;
ItemQueue<ItemHistoryStart> _recent;
ItemQueue<MaxItemsArchive> _archived;
bool activeItemShouldBeArchived() const;
void tickActiveItem();
};
void InitQueue(Park::ParkData& park);
void UpdateCurrentItem(ItemQueues& queues);
void CloseCurrentItem(ItemQueues& queues);
std::optional<CoordsXYZ> GetSubjectLocation(ItemType type, int32_t subject);
Item* AddItemToQueue(ItemQueues& queues, ItemType type, StringId string_id, uint32_t assoc, const Formatter& formatter);
Item* AddItemToQueue(ItemQueues& queues, ItemType type, StringId string_id, EntityId assoc, const Formatter& formatter);
Item* AddItemToQueue(ItemQueues& queues, ItemType type, const utf8* text, uint32_t assoc);
bool CheckIfItemRequiresAssoc(ItemType type);
void OpenSubject(ItemType type, int32_t subject);
void DisableNewsItems(ItemQueues& queues, ItemType type, uint32_t assoc);
Item* GetItem(ItemQueues& queues, int32_t index);
bool IsValidIndex(int32_t index);
void AddItemToQueue(ItemQueues& queues, Item* newNewsItem);
void RemoveItem(ItemQueues& queues, int32_t index);
void importNewsItems(ItemQueues& queues, std::span<const Item> recent, std::span<const Item> archived);
void DisableNewsItems(Items& newsItems, ItemType type, uint32_t assoc);
} // namespace OpenRCT2::News
+6 -15
View File
@@ -266,8 +266,8 @@ void ResearchFinishItem(const ResearchItem& researchItem)
{
if (Config::Get().notifications.rideResearched)
{
News::AddItemToQueue(
gameState.park.newsItems, News::ItemType::research, availabilityString, researchItem.rawValue, ft);
gameState.park.newsItems.addItemToQueue(
News::ItemType::research, availabilityString, researchItem.rawValue, ft);
}
}
@@ -290,9 +290,8 @@ void ResearchFinishItem(const ResearchItem& researchItem)
{
if (Config::Get().notifications.rideResearched)
{
News::AddItemToQueue(
gameState.park.newsItems, News::ItemType::research, STR_NEWS_ITEM_RESEARCH_NEW_SCENERY_SET_AVAILABLE,
researchItem.rawValue, ft);
gameState.park.newsItems.addItemToQueue(
News::ItemType::research, STR_NEWS_ITEM_RESEARCH_NEW_SCENERY_SET_AVAILABLE, researchItem.rawValue, ft);
}
}
@@ -1100,20 +1099,12 @@ void ResearchDetermineFirstOfType()
if (gameState.researchNextItem.has_value())
{
ResearchUpdateFirstOfType(&gameState.researchNextItem.value());
ResearchMarkRideTypeAsSeen(gameState.researchNextItem.value());
// The next research item is (sometimes?) also present in gameState.researchItemsUninvented. To make things worse,
// the base ride entry or the entry index of researchNextItem may be corrupted.
}
for (auto& researchItem : gameState.researchItemsUninvented)
{
// The next research item is (sometimes?) also present in gameState.researchItemsUninvented
if (gameState.researchNextItem.has_value() && !gameState.researchNextItem->isNull()
&& researchItem.baseRideType == gameState.researchNextItem.value().baseRideType)
{
// Copy the "first of type" flag.
researchItem.flags = gameState.researchNextItem->flags;
continue;
}
ResearchUpdateFirstOfType(&researchItem);
ResearchMarkRideTypeAsSeen(researchItem);
}
+3 -1
View File
@@ -47,7 +47,7 @@
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
constexpr uint8_t kStreamVersion = 0;
constexpr uint8_t kStreamVersion = 1;
const std::string kStreamID = std::string(kOpenRCT2Version) + "-" + std::to_string(kStreamVersion);
@@ -105,6 +105,8 @@ namespace OpenRCT2::Network
static void ChatAddHistory(const u8string& text)
{
AppendChatLog(text);
auto intent = Intent(INTENT_ACTION_CHAT_ADD_HISTORY);
intent.PutExtra(INTENT_EXTRA_MESSAGE, text);
ContextBroadcastIntent(&intent);
+17 -28
View File
@@ -14,8 +14,6 @@
#include "../OpenRCT2.h"
#include "../PlatformEnvironment.h"
#include "../SpriteIds.h"
#include "../core/File.h"
#include "../core/FileScanner.h"
#include "../core/Guard.hpp"
#include "../core/IStream.hpp"
#include "../core/Json.hpp"
@@ -381,42 +379,33 @@ namespace OpenRCT2
std::string ImageTable::FindLegacyObject(const std::string& name)
{
// The original object files are looked up through the platform environment, which resolves
// their name case insensitively from a cached directory listing. Scanning the directory per
// look up instead is very slow on file systems with a high per-operation cost, and the game
// asks for hundreds of these files whenever it loads a park.
const auto& env = GetContext()->GetPlatformEnvironment();
auto objectsPath = env.GetDirectoryPath(DirBase::rct2, DirId::objects);
auto objectPath = Path::Combine(objectsPath, name);
if (File::Exists(objectPath))
auto objectPath = env.FindFile(DirBase::rct2, DirId::objects, name);
if (!objectPath.empty())
{
return objectPath;
}
std::string altName = name;
auto rangeStart = name.find(".DAT");
if (rangeStart != std::string::npos)
// RCT Classic ships the same objects with a .POB extension
auto extensionStart = name.find(".DAT");
if (extensionStart != std::string::npos)
{
altName.replace(rangeStart, 4, ".POB");
}
objectPath = Path::Combine(objectsPath, altName);
if (File::Exists(objectPath))
{
return objectPath;
}
auto altName = name;
altName.replace(extensionStart + 1, 3, "POB");
if (!File::Exists(objectPath))
{
// Search recursively for any file with the target name (case insensitive)
auto filter = Path::Combine(objectsPath, u8"*.dat;*.pob");
auto scanner = Path::scanDirectory(filter, true);
while (scanner->next())
objectPath = env.FindFile(DirBase::rct2, DirId::objects, altName);
if (!objectPath.empty())
{
auto currentName = Path::GetFileName(scanner->getPathRelative());
if (String::iequals(currentName, name) || String::iequals(currentName, altName))
{
objectPath = scanner->getPath();
break;
}
return objectPath;
}
}
return objectPath;
// Return the path the object was expected at, so that failing to open it can be reported
return Path::Combine(env.GetDirectoryPath(DirBase::rct2, DirId::objects), name);
}
ImageTable::~ImageTable()
-91
View File
@@ -308,97 +308,6 @@ namespace OpenRCT2
return !(*this == rhs);
}
bool ObjectAsset::IsAvailable() const
{
if (_zipPath.empty())
{
return File::Exists(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
return zipArchive != nullptr && zipArchive->Exists(_path);
}
uint64_t ObjectAsset::GetSize() const
{
if (_zipPath.empty())
{
return File::GetSize(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
auto index = zipArchive->GetIndexFromPath(_path);
if (index.has_value())
{
auto size = zipArchive->GetFileSize(index.value());
return size;
}
}
return 0;
}
std::vector<uint8_t> ObjectAsset::GetData() const
{
if (_zipPath.empty())
{
return File::ReadAllBytes(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
return zipArchive->GetFileData(_path);
}
return {};
}
std::unique_ptr<IStream> ObjectAsset::GetStream() const
{
try
{
if (_zipPath.empty())
{
return std::make_unique<FileStream>(_path, FileMode::open);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
auto stream = zipArchive->GetFileStream(_path);
if (stream != nullptr)
{
return std::make_unique<ZipStreamWrapper>(std::move(zipArchive), std::move(stream));
}
}
}
catch (...)
{
}
return {};
}
const std::string& ObjectAsset::GetZipPath() const
{
return _zipPath;
}
const std::string& ObjectAsset::GetPath() const
{
return _path;
}
size_t ObjectAsset::GetHash() const
{
// Combine hashes of zipPath and path
std::hash<std::string> hasher;
auto h1 = hasher(_zipPath);
auto h2 = hasher(_path);
// Combine the hashes based on example from https://en.cppreference.com/w/cpp/utility/hash.html
return h1 ^ (h2 << 1);
}
u8string VersionString(const ObjectVersion& version)
{
return std::to_string(std::get<0>(version)) + "." + std::to_string(std::get<1>(version)) + "."
+110
View File
@@ -0,0 +1,110 @@
/*****************************************************************************
* 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.
*****************************************************************************/
#include "ObjectAsset.h"
#include "../core/File.h"
#include "../core/FileStream.h"
#include "../core/Zip.h"
#include "../core/ZipStream.hpp"
namespace OpenRCT2
{
bool ObjectAsset::IsAvailable() const
{
if (_zipPath.empty())
{
return File::Exists(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
return zipArchive != nullptr && zipArchive->Exists(_path);
}
uint64_t ObjectAsset::GetSize() const
{
if (_zipPath.empty())
{
return File::GetSize(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
auto index = zipArchive->GetIndexFromPath(_path);
if (index.has_value())
{
auto size = zipArchive->GetFileSize(index.value());
return size;
}
}
return 0;
}
std::vector<uint8_t> ObjectAsset::GetData() const
{
if (_zipPath.empty())
{
return File::ReadAllBytes(_path);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
return zipArchive->GetFileData(_path);
}
return {};
}
std::unique_ptr<IStream> ObjectAsset::GetStream() const
{
try
{
if (_zipPath.empty())
{
return std::make_unique<FileStream>(_path, FileMode::open);
}
auto zipArchive = Zip::TryOpen(_zipPath, ZipAccess::read);
if (zipArchive != nullptr)
{
auto stream = zipArchive->GetFileStream(_path);
if (stream != nullptr)
{
return std::make_unique<ZipStreamWrapper>(std::move(zipArchive), std::move(stream));
}
}
}
catch (...)
{
}
return {};
}
const std::string& ObjectAsset::GetZipPath() const
{
return _zipPath;
}
const std::string& ObjectAsset::GetPath() const
{
return _path;
}
size_t ObjectAsset::GetHash() const
{
// Combine hashes of zipPath and path
std::hash<std::string> hasher;
auto h1 = hasher(_zipPath);
auto h2 = hasher(_path);
// Combine the hashes based on example from https://en.cppreference.com/w/cpp/utility/hash.html
return h1 ^ (h2 << 1);
}
} // namespace OpenRCT2
+10
View File
@@ -9,6 +9,7 @@
#pragma once
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
@@ -17,6 +18,15 @@ namespace OpenRCT2
{
struct IStream;
/**
* A wrapper for an object held in a file or as a file within a zip
* archive.
*
* If only a `path` is provided, GetStream() and GetData() will return the
* content of the file directly. If a `zipPath` and `path` are provided,
* GetStream() and GetData() will return the content of the file at `path`
* within the zip archive at `zipPath`.
*/
class ObjectAsset
{
private:
+9 -2
View File
@@ -35,6 +35,7 @@
#include "LargeSceneryObject.h"
#include "MusicObject.h"
#include "Object.h"
#include "ObjectAsset.h"
#include "ObjectLimits.h"
#include "PathAdditionObject.h"
#include "PeepAnimationsObject.h"
@@ -529,9 +530,15 @@ namespace OpenRCT2::ObjectFactory
std::unique_ptr<Object> CreateObjectFromJson(
json_t& jRoot, const IFileDataRetriever* fileRetriever, bool loadImageTable, const std::string_view path)
{
if (!jRoot.is_object())
if (!jRoot.is_object() || !jRoot.contains("objectType"))
{
throw std::runtime_error("Object JSON root was not an object");
LOG_VERBOSE("Ignoring JSON file (%.*s): not an object file", static_cast<int>(path.length()), path.data());
return nullptr;
}
if (!jRoot["objectType"].is_string())
{
LOG_VERBOSE("Ignoring JSON file (%.*s): objectType is not a string", static_cast<int>(path.length()), path.data());
return nullptr;
}
LOG_VERBOSE("CreateObjectFromJson(...)");
@@ -10,6 +10,7 @@
#include "TerrainSurfaceObject.h"
#include "../Context.h"
#include "../OpenRCT2.h"
#include "../core/Guard.hpp"
#include "../core/Json.hpp"
#include "../drawing/ColourMap.h"
@@ -34,6 +35,9 @@ namespace OpenRCT2
void TerrainSurfaceObject::precolourPatternImages()
{
if (gOpenRCT2NoGraphics)
return;
for (size_t colourNum = 0; colourNum < Drawing::kColourNumTotal; colourNum++)
{
for (uint8_t patternOffset = 0; patternOffset < kNumSmoothingPatternImages; patternOffset++)
@@ -76,6 +80,9 @@ namespace OpenRCT2
void TerrainSurfaceObject::unloadPrecolouredPatternImages()
{
if (gOpenRCT2NoGraphics)
return;
GfxObjectFreeImages(precolouredPatternImageId, precolouredPatternImages.GetCount());
precolouredPatternImageId = 0;
}
+2 -2
View File
@@ -316,9 +316,9 @@ void VirtualFloorPaint(PaintSession& session)
// Try the four tiles next to us for the same parameters as above,
// if our parameters differ we set an edge towards that tile
for (uint8_t i = 0; i < kNumOrthogonalDirections; i++)
for (Direction i : kAllDirections)
{
uint8_t effectiveRotation = (kNumOrthogonalDirections + i - direction) % kNumOrthogonalDirections;
Direction effectiveRotation = (kNumOrthogonalDirections + i - direction) % kNumOrthogonalDirections;
CoordsXY theirLocation = session.MapPosition + scenery_half_tile_offsets[effectiveRotation];
bool theyAreOccupied;
@@ -39,7 +39,7 @@ void PaintUtilSetVerticalTunnel(PaintSession& session, uint16_t height)
session.VerticalTunnelHeight = height / 16;
}
void PaintUtilPushTunnelRotated(PaintSession& session, uint8_t direction, uint16_t height, TunnelType type)
void PaintUtilPushTunnelRotated(PaintSession& session, Direction direction, uint16_t height, TunnelType type)
{
if (direction & 1)
{
@@ -83,7 +83,7 @@ TunnelType GetTunnelType(TunnelGroup tunnelGroup, TunnelSubType tunnelSubType);
void PaintUtilPushTunnelLeft(PaintSession& session, uint16_t height, TunnelType type);
void PaintUtilPushTunnelRight(PaintSession& session, uint16_t height, TunnelType type);
void PaintUtilSetVerticalTunnel(PaintSession& session, uint16_t height);
void PaintUtilPushTunnelRotated(PaintSession& session, uint8_t direction, uint16_t height, TunnelType type);
void PaintUtilPushTunnelRotated(PaintSession& session, Direction direction, uint16_t height, TunnelType type);
inline void PaintUtilPushTunnelLeft(
PaintSession& session, uint16_t height, TunnelGroup tunnelGroup, TunnelSubType tunnelSubType)
@@ -98,7 +98,7 @@ inline void PaintUtilPushTunnelRight(
}
inline void PaintUtilPushTunnelRotated(
PaintSession& session, uint8_t direction, uint16_t height, TunnelGroup tunnelGroup, TunnelSubType tunnelSubType)
PaintSession& session, Direction direction, uint16_t height, TunnelGroup tunnelGroup, TunnelSubType tunnelSubType)
{
PaintUtilPushTunnelRotated(session, direction, height, GetTunnelType(tunnelGroup, tunnelSubType));
}
+1 -1
View File
@@ -27,7 +27,7 @@ namespace OpenRCT2
{
const size_t directionOffset = sequenceCount * spriteCount;
uint64_t spriteMap = 0;
for (size_t direction = 0; direction < kNumOrthogonalDirections; direction++)
for (Direction direction : kAllDirections)
{
for (size_t sequence = 0; sequence < sequenceCount; sequence++)
{
+5 -5
View File
@@ -1212,25 +1212,25 @@ namespace OpenRCT2
cs.readWrite(item.category);
}
void ReadWriteNotificationsChunk(News::ItemQueues& queues, OrcaStream& os)
void ReadWriteNotificationsChunk(News::Items& queues, OrcaStream& os)
{
os.readWriteChunk(ParkFileChunkType::notifications, [&queues](OrcaStream::ChunkStream& cs) {
if (cs.getMode() == OrcaStream::Mode::reading)
{
std::vector<News::Item> recent;
cs.readWriteVector(recent, [&cs](News::Item& item) { ReadWriteNewsItem(cs, item); });
queues.queue.importQueue(recent);
std::vector<News::Item> archived;
cs.readWriteVector(archived, [&cs](News::Item& item) { ReadWriteNewsItem(cs, item); });
News::importNewsItems(queues, recent, archived);
queues.archive.importQueue(archived);
}
else
{
std::vector<News::Item> recent(std::begin(queues.getRecent()), std::end(queues.getRecent()));
std::vector<News::Item> recent(std::begin(queues.queue), std::end(queues.queue));
cs.readWriteVector(recent, [&cs](News::Item& item) { ReadWriteNewsItem(cs, item); });
std::vector<News::Item> archived(std::begin(queues.getArchived()), std::end(queues.getArchived()));
std::vector<News::Item> archived(std::begin(queues.archive), std::end(queues.archive));
cs.readWriteVector(archived, [&cs](News::Item& item) { ReadWriteNewsItem(cs, item); });
}
});
+1 -1
View File
@@ -58,7 +58,7 @@ static const wchar_t* _wszArchitecture = WSZ(OPENRCT2_ARCHITECTURE);
static std::map<std::wstring, std::wstring> _uploadFiles;
static std::mutex _uploadFilesMutex;
#define BACKTRACE_TOKEN "f509d427f8ee73ef96c59c46a0c8ef5f79d9cac9ed5f014da986e3bb15a24389"
#define BACKTRACE_TOKEN "25e2ab471a2fc23d2ab786112eaf5d316e84721badd080c7347e405812e204db"
using namespace OpenRCT2;
+2 -1
View File
@@ -2291,8 +2291,9 @@ namespace OpenRCT2::RCT1
// News items
auto recentMessages = convertNewsQueue(_s4.recentMessages);
park.newsItems.queue.importQueue(recentMessages);
auto archivedMessages = convertNewsQueue(_s4.archivedMessages);
News::importNewsItems(park.newsItems, recentMessages, archivedMessages);
park.newsItems.archive.importQueue(archivedMessages);
// Initial guest status
gameState.scenarioOptions.guestInitialCash = ToMoney64(_s4.GuestInitialCash);
+1 -1
View File
@@ -324,7 +324,7 @@ namespace OpenRCT2::RCT2
constexpr Direction GetDirection() const
{
return (direction & 0b00001111);
return direction & 0b00000011;
}
constexpr bool IsExit() const
+3 -2
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;
@@ -594,8 +594,9 @@ namespace OpenRCT2::RCT2
// News items
auto recentMessages = convertNewsQueue(_s6.recentMessages);
park.newsItems.queue.importQueue(recentMessages);
auto archivedMessages = convertNewsQueue(_s6.archivedMessages);
News::importNewsItems(park.newsItems, recentMessages, archivedMessages);
park.newsItems.archive.importQueue(archivedMessages);
// Pad13CE730
// rct1_scenario_flags
+14 -15
View File
@@ -1345,8 +1345,9 @@ namespace OpenRCT2
{
Formatter ft;
ride.formatNameTo(ft);
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::ride, STR_RIDE_IS_BROKEN_DOWN, ride.id.ToUnderlying(), ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::ride, STR_RIDE_IS_BROKEN_DOWN, ride.id.ToUnderlying(), ft);
}
}
@@ -1373,9 +1374,8 @@ namespace OpenRCT2
{
Formatter ft;
ride.formatNameTo(ft);
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::ride, STR_RIDE_IS_STILL_NOT_FIXED,
ride.id.ToUnderlying(), ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::ride, STR_RIDE_IS_STILL_NOT_FIXED, ride.id.ToUnderlying(), ft);
}
}
}
@@ -2065,9 +2065,8 @@ namespace OpenRCT2
ride.formatNameTo(ft);
if (Config::Get().notifications.rideWarnings)
{
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::ride, STR_ENTRANCE_NOT_CONNECTED, ride.id.ToUnderlying(),
ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::ride, STR_ENTRANCE_NOT_CONNECTED, ride.id.ToUnderlying(), ft);
}
ride.connectedMessageThrottle = 3;
}
@@ -2079,9 +2078,8 @@ namespace OpenRCT2
ride.formatNameTo(ft);
if (Config::Get().notifications.rideWarnings)
{
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::ride, STR_EXIT_NOT_CONNECTED, ride.id.ToUnderlying(),
ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::ride, STR_EXIT_NOT_CONNECTED, ride.id.ToUnderlying(), ft);
}
ride.connectedMessageThrottle = 3;
}
@@ -2148,8 +2146,9 @@ namespace OpenRCT2
{
Formatter ft;
ride2->formatNameTo(ft);
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::ride, STR_ENTRANCE_NOT_CONNECTED, ride2->id.ToUnderlying(), ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::ride, STR_ENTRANCE_NOT_CONNECTED, ride2->id.ToUnderlying(), ft);
}
ride2->connectedMessageThrottle = 3;
@@ -5047,8 +5046,8 @@ namespace OpenRCT2
{
Formatter ft;
formatNameTo(ft);
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::ride, STR_RIDE_HAS_CRASHED, id.ToUnderlying(), ft);
getGameState().park.newsItems.addItemToQueue(News::ItemType::ride, STR_RIDE_HAS_CRASHED, id.ToUnderlying(), ft);
}
}
+42 -12
View File
@@ -2247,35 +2247,55 @@ namespace OpenRCT2::TrackMetadata
.allowedWallEdges = 0b1010,
.flags = { SequenceFlag::hasHeightMarker },
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = kFlatStraightBlockedSegments,
.blockedSegments = { {
kSegmentsUnimplemented, // narrow
kSegmentsUnimplemented, // inverted
kSegmentsAll, // wide
} },
};
static constexpr SequenceDescriptor kReverseFreefallSlopeSeq1 = {
.clearance = { -32, 0, 0, 32, { 0b1111, 0 }, {} },
.allowedWallEdges = 0b1010,
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = kFlatStraightBlockedSegments,
.blockedSegments = { {
kSegmentsUnimplemented, // narrow
kSegmentsUnimplemented, // inverted
kSegmentsAll, // wide
} },
};
static constexpr SequenceDescriptor kReverseFreefallSlopeSeq2 = {
.clearance = { -64, 0, 0, 48, { 0b1111, 0 }, {} },
.allowedWallEdges = 0b1010,
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = kFlatStraightBlockedSegments,
.blockedSegments = { {
kSegmentsUnimplemented, // narrow
kSegmentsUnimplemented, // inverted
kSegmentsAll, // wide
} },
};
static constexpr SequenceDescriptor kReverseFreefallSlopeSeq3 = {
.clearance = { -96, 0, 0, 80, { 0b1111, 0 }, {} },
.allowedWallEdges = 0b1010,
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = kFlatStraightBlockedSegments,
.blockedSegments = { {
kSegmentsUnimplemented, // narrow
kSegmentsUnimplemented, // inverted
kSegmentsAll, // wide
} },
};
static constexpr SequenceDescriptor kReverseFreefallSlopeSeq4 = {
.clearance = { -128, 0, 0, 160, { 0b1111, 0 }, {} },
.allowedWallEdges = 0b1010,
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = kFlatStraightBlockedSegments,
.blockedSegments = { {
kSegmentsUnimplemented, // narrow
kSegmentsUnimplemented, // inverted
kSegmentsAll, // wide
} },
};
static constexpr SequenceDescriptor kReverseFreefallSlopeSeq5 = {
@@ -2283,13 +2303,22 @@ namespace OpenRCT2::TrackMetadata
.allowedWallEdges = 0b1011,
.flags = { SequenceFlag::hasHeightMarker },
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = kFlatStraightBlockedSegments,
.blockedSegments = { {
kSegmentsUnimplemented, // narrow
kSegmentsUnimplemented, // inverted
kSegmentsAll, // wide
} },
};
static constexpr SequenceDescriptor kReverseFreefallSlopeSeq6 = {
.clearance = { -160, 0, 0, 208, { 0b1111, 0 }, {} },
.allowedWallEdges = 0b1010,
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = kFlatStraightBlockedSegments,
.blockedSegments = { {
kSegmentsUnimplemented, // narrow
kSegmentsUnimplemented, // inverted
kSegmentsAll, // wide
} },
};
static constexpr SequenceDescriptor kReverseFreefallVerticalSeq0 = {
@@ -4533,7 +4562,6 @@ namespace OpenRCT2::TrackMetadata
static constexpr SequenceDescriptor kAirThrustVerticalDownToLevelSeq0 = {
.clearance = { 0, 0, 0, 208, { 0b1111, 0 }, {} },
.allowedWallEdges = 0b1010,
.flags = { SequenceFlag::hasHeightMarker },
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = { {
kSegmentsUnimplemented, // narrow
@@ -4544,7 +4572,8 @@ namespace OpenRCT2::TrackMetadata
static constexpr SequenceDescriptor kAirThrustVerticalDownToLevelSeq1 = {
.clearance = { 32, 0, 0, 208, { 0b1111, 0 }, {} },
.allowedWallEdges = 0b1010,
.allowedWallEdges = 0b1110,
.flags = { SequenceFlag::hasHeightMarker },
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = { {
kSegmentsUnimplemented, // narrow
@@ -4589,7 +4618,6 @@ namespace OpenRCT2::TrackMetadata
static constexpr SequenceDescriptor kAirThrustVerticalDownToLevelSeq5 = {
.clearance = { -128, 0, 0, 32, { 0b1111, 0 }, {} },
.allowedWallEdges = 0b1010,
.flags = { SequenceFlag::hasHeightMarker },
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = { {
kSegmentsUnimplemented, // narrow
@@ -4600,6 +4628,8 @@ namespace OpenRCT2::TrackMetadata
static constexpr SequenceDescriptor kAirThrustVerticalDownToLevelSeq6 = {
.clearance = { -160, 0, 0, 16, { 0b1111, 0 }, {} },
.allowedWallEdges = 0b1010,
.flags = { SequenceFlag::hasHeightMarker },
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = { {
kSegmentsUnimplemented, // narrow
@@ -5531,6 +5561,7 @@ namespace OpenRCT2::TrackMetadata
static constexpr SequenceDescriptor kLeftEighthToOrthogonalUp25Seq4 = {
.clearance = { -64, 32, 32, 16, { 0b1111, 0 }, {} },
.allowedWallEdges = 0b0010,
.flags = { SequenceFlag::hasHeightMarker },
.woodenSupports = { WoodenSupportSubType::neSw },
.blockedSegments = blockedSegmentsRotate(kRightEighthToDiagUp25Seq0.blockedSegments, 2),
};
@@ -6142,7 +6173,6 @@ namespace OpenRCT2::TrackMetadata
static constexpr SequenceDescriptor kDiagFlatToLeftBankedDown25Seq0 = {
.clearance = { 0, 0, 0, 8, { 0b1101, 0 }, {} },
.flags = { SequenceFlag::hasHeightMarker },
.blockedSegments = kDiagFlatSeq0.blockedSegments,
};
@@ -6162,6 +6192,7 @@ namespace OpenRCT2::TrackMetadata
static constexpr SequenceDescriptor kDiagFlatToLeftBankedDown25Seq3 = {
.clearance = { -32, 32, 0, 8, { 0b0010, 0 }, {} },
.flags = { SequenceFlag::hasHeightMarker },
.blockedSegments = kDiagFlatSeq3.blockedSegments,
};
@@ -6587,7 +6618,6 @@ namespace OpenRCT2::TrackMetadata
static constexpr SequenceDescriptor kRightEighthBankToOrthogonalDown25Seq0 = {
.clearance = { 0, 0, -16, 24, { 0b1101, 0 }, {} },
.flags = { SequenceFlag::hasHeightMarker },
.woodenSupports = { WoodenSupportSubType::neSw, WoodenSupportTransitionType::up25Deg },
.extraSupportRotation = 2,
.blockedSegments = kRightEighthBankToOrthogonalUp25Seq0.blockedSegments,
+1 -1
View File
@@ -2162,7 +2162,7 @@ void TrackDesignDrawPreview(TrackDesign& td, TrackDesignPreviewBuffer& pixels, b
drawingEngine->BeginDraw();
const ScreenCoordsXY offset = { size_x / 2, size_y / 2 };
for (Direction direction = 0; direction < kNumOrthogonalDirections; direction++)
for (Direction direction : kAllDirections)
{
view.viewPos = Translate3DTo2DWithZ(direction, centre) - offset;
view.rotation = direction;
+1 -1
View File
@@ -284,7 +284,7 @@ namespace OpenRCT2
int32_t y = input->y;
int32_t OriginZ = inputElement->getBaseZ();
uint8_t rotation = inputElement->getDirection();
Direction rotation = inputElement->getDirection();
CoordsXY coords = { x, y };
CoordsXY trackCoordOffset = { trackCoordinate.x, trackCoordinate.y };
+4 -3
View File
@@ -296,9 +296,10 @@ static void ride_train_crash(Ride& ride, uint16_t numFatalities)
if (Config::Get().notifications.rideCasualties)
{
ride.formatNameTo(ft);
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::ride,
numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X, ride.id.ToUnderlying(), ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::ride, numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X,
ride.id.ToUnderlying(), ft);
}
// TODO: get park id from ride/vehicle
+3 -3
View File
@@ -165,7 +165,7 @@ static bool ride_station_can_depart_synchronised(const Ride& ride, StationIndex
* is found we allow for space between that and the next.
*/
int32_t direction = tileElement->getDirectionWithOffset(1);
Direction direction = tileElement->getDirectionWithOffset(1);
constexpr uint8_t maxCheckDistance = kRideAdjacencyCheckDistance;
uint8_t spaceBetween = maxCheckDistance;
@@ -1329,8 +1329,8 @@ void Vehicle::CheckIfMissing()
curRide->formatNameTo(ft);
ft.Add<StringId>(GetRideComponentName(GetRideTypeDescriptor(curRide->type).NameConvention.station).singular);
News::AddItemToQueue(
getGameState().park.newsItems, News::ItemType::ride, STR_NEWS_VEHICLE_HAS_STALLED, ride.ToUnderlying(), ft);
getGameState().park.newsItems.addItemToQueue(
News::ItemType::ride, STR_NEWS_VEHICLE_HAS_STALLED, ride.ToUnderlying(), ft);
}
}
+9 -9
View File
@@ -217,7 +217,7 @@ static void ScenarioCheckEntranceFeeTooHigh()
uint32_t packed_xy = (y << 16) | x;
if (Config::Get().notifications.parkWarnings)
{
News::AddItemToQueue(park.newsItems, News::ItemType::blank, STR_ENTRANCE_FEE_TOO_HI, packed_xy, {});
park.newsItems.addItemToQueue(News::ItemType::blank, STR_ENTRANCE_FEE_TOO_HI, packed_xy, {});
}
}
}
@@ -272,20 +272,20 @@ static void scenarioUpdateLowRatingDayCount(Park::ParkData& park, GameState_t& g
switch (park.scenarioParkRatingWarningDays)
{
case 1:
News::AddItemToQueue(
park.newsItems, News::ItemType::graph, STR_PARK_RATING_WARNING_4_WEEKS_REMAINING, 0, {});
park.newsItems.addItemToQueue(News::ItemType::graph, STR_PARK_RATING_WARNING_4_WEEKS_REMAINING, 0, {});
break;
case 8:
News::AddItemToQueue(
park.newsItems, News::ItemType::graph, STR_PARK_RATING_WARNING_3_WEEKS_REMAINING, 0, {});
park.newsItems.addItemToQueue(News::ItemType::graph, STR_PARK_RATING_WARNING_3_WEEKS_REMAINING, 0, {});
break;
case 15:
News::AddItemToQueue(
park.newsItems, News::ItemType::graph, STR_PARK_RATING_WARNING_2_WEEKS_REMAINING, 0, {});
park.newsItems.addItemToQueue(News::ItemType::graph, STR_PARK_RATING_WARNING_2_WEEKS_REMAINING, 0, {});
break;
case 22:
News::AddItemToQueue(
park.newsItems, News::ItemType::graph, STR_PARK_RATING_WARNING_1_WEEK_REMAINING, 0, {});
park.newsItems.addItemToQueue(News::ItemType::graph, STR_PARK_RATING_WARNING_1_WEEK_REMAINING, 0, {});
break;
}
}
+1 -1
View File
@@ -257,7 +257,7 @@ namespace OpenRCT2::Scenario
{
case ObjectiveType::guestsAndRating:
{
News::AddItemToQueue(park.newsItems, News::ItemType::graph, STR_PARK_HAS_BEEN_CLOSED_DOWN, 0, {});
park.newsItems.addItemToQueue(News::ItemType::graph, STR_PARK_HAS_BEEN_CLOSED_DOWN, 0, {});
park.flags.unset(ParkFlag::parkOpen);
gameState.scenarioOptions.guestInitialHappiness = 50;
break;
@@ -183,7 +183,7 @@ namespace OpenRCT2::Editor
for (const auto& parkEntrance : gameState.park.entrances)
{
int32_t direction = DirectionReverse(parkEntrance.direction);
Direction direction = DirectionReverse(parkEntrance.direction);
switch (FootpathIsConnectedToMapEdge(parkEntrance, direction, 0))
{
+2
View File
@@ -333,6 +333,8 @@ namespace OpenRCT2::Scripting
classId = JS_INVALID_CLASS_ID;
if (protoCtx != nullptr)
JS_FreeValue(protoCtx, proto);
proto = JS_NULL;
protoCtx = nullptr;
}
[[nodiscard]] JSValue GetProto() const
@@ -63,6 +63,7 @@ namespace OpenRCT2::Scripting
JS_CGETSET_DEF("maxLiftHillSpeed", ScRide::maxLiftHillSpeed_get, nullptr),
JS_CGETSET_DEF("minLiftHillSpeed", ScRide::minLiftHillSpeed_get, nullptr),
JS_CGETSET_DEF("satisfaction", ScRide::satisfaction_get, nullptr),
JS_CGETSET_DEF("popularity", ScRide::popularity_get, nullptr),
JS_CGETSET_DEF("maxSpeed", ScRide::maxSpeed_get, nullptr),
JS_CGETSET_DEF("averageSpeed", ScRide::averageSpeed_get, nullptr),
JS_CGETSET_DEF("rideTime", ScRide::rideTime_get, nullptr),
@@ -732,7 +733,17 @@ namespace OpenRCT2::Scripting
JSValue ScRide::satisfaction_get(JSContext* ctx, JSValue thisVal)
{
auto ride = GetRide(thisVal);
return JS_NewUint32(ctx, ride != nullptr ? ride->satisfaction * 5 : 0);
if (ride == nullptr || ride->satisfaction == 255)
return JS_NULL;
return JS_NewUint32(ctx, ride->satisfaction * 5);
}
JSValue ScRide::popularity_get(JSContext* ctx, JSValue thisVal)
{
auto ride = GetRide(thisVal);
if (ride == nullptr || ride->popularity == 255)
return JS_NULL;
return JS_NewUint32(ctx, ride->popularity * 4);
}
JSValue ScRide::maxSpeed_get(JSContext* ctx, JSValue thisVal)
@@ -133,6 +133,7 @@ namespace OpenRCT2::Scripting
static JSValue maxLiftHillSpeed_get(JSContext* ctx, JSValue thisVal);
static JSValue minLiftHillSpeed_get(JSContext* ctx, JSValue thisVal);
static JSValue satisfaction_get(JSContext* ctx, JSValue thisVal);
static JSValue popularity_get(JSContext* ctx, JSValue thisVal);
static JSValue maxSpeed_get(JSContext* ctx, JSValue thisVal);
static JSValue averageSpeed_get(JSContext* ctx, JSValue thisVal);
static JSValue rideTime_get(JSContext* ctx, JSValue thisVal);
@@ -11,6 +11,7 @@
#include "ScRideStation.hpp"
#include "../../../core/UnitConversion.h"
#include "../../../ride/Ride.h"
namespace OpenRCT2::Scripting
@@ -23,6 +24,7 @@ namespace OpenRCT2::Scripting
JS_CGETSET_DEF("entrance", ScRideStation::entrance_get, ScRideStation::entrance_set),
JS_CGETSET_DEF("exit", ScRideStation::exit_get, ScRideStation::exit_set),
JS_CGETSET_DEF("queueTime", ScRideStation::queueTime_get, nullptr),
JS_CGETSET_DEF("segmentLength", ScRideStation::segmentLength_get, nullptr),
};
RegisterBase(ctx, "RideStation", Finalize, funcs);
}
@@ -102,6 +104,12 @@ namespace OpenRCT2::Scripting
return JS_UNDEFINED;
}
JSValue ScRideStation::segmentLength_get(JSContext* ctx, JSValue thisVal)
{
auto station = GetRideStation(thisVal);
return JS_NewInt32(ctx, station != nullptr ? ToHumanReadableRideLength(station->segmentLength) : 0);
}
JSValue ScRideStation::entrance_get(JSContext* ctx, JSValue thisVal)
{
auto station = GetRideStation(thisVal);
@@ -51,6 +51,7 @@ namespace OpenRCT2::Scripting
static JSValue exit_get(JSContext* ctx, JSValue thisVal);
static JSValue exit_set(JSContext* ctx, JSValue thisVal, JSValue value);
static JSValue queueTime_get(JSContext* ctx, JSValue thisVal);
static JSValue segmentLength_get(JSContext* ctx, JSValue thisVal);
};
} // namespace OpenRCT2::Scripting
@@ -357,13 +357,13 @@ namespace OpenRCT2::Scripting
JSValue result = JS_NewArray(ctx);
int64_t resultIdx = 0;
auto& newsItems = getGameState().park.newsItems;
for (size_t i = 0, newsSize = newsItems.getRecent().size(); i < newsSize; i++)
for (size_t i = 0, newsSize = newsItems.queue.size(); i < newsSize; i++)
{
JS_SetPropertyInt64(ctx, result, resultIdx++, gScParkMessage.New(ctx, i));
}
for (size_t i = 0, newsSize = newsItems.getArchived().size(); i < newsSize; i++)
for (size_t i = 0, newsSize = newsItems.archive.size(); i < newsSize; i++)
{
auto offset = i + News::ItemHistoryStart;
auto offset = i + News::kNewsQueueSize;
JS_SetPropertyInt64(ctx, result, resultIdx++, gScParkMessage.New(ctx, offset));
}
return result;
@@ -371,38 +371,38 @@ namespace OpenRCT2::Scripting
JSValue ScPark::messages_set(JSContext* ctx, JSValue thisVal, JSValue value)
{
int32_t index = 0;
int32_t archiveIndex = News::ItemHistoryStart;
size_t queueIndex = 0;
size_t archiveIndex = 0;
auto& newsItems = getGameState().park.newsItems;
JSIterateArray(ctx, value, [&index, &archiveIndex, &newsItems](JSContext* ctx2, JSValue item) {
JSIterateArray(ctx, value, [&queueIndex, &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 < newsItems.archive.capacity())
{
newsItems[archiveIndex] = newsItem;
newsItems.archive[archiveIndex] = newsItem;
archiveIndex++;
}
}
else
{
if (index < News::ItemHistoryStart)
if (queueIndex < newsItems.queue.capacity())
{
newsItems[index] = newsItem;
index++;
newsItems.queue[queueIndex] = newsItem;
queueIndex++;
}
}
});
// End the lists by setting next item to null
if (index < News::ItemHistoryStart)
if (queueIndex < newsItems.queue.capacity())
{
newsItems[index].type = News::ItemType::null;
newsItems.queue[queueIndex].type = News::ItemType::null;
}
if (archiveIndex < News::MaxItems)
if (archiveIndex < newsItems.archive.capacity())
{
newsItems[archiveIndex].type = News::ItemType::null;
newsItems.archive[archiveIndex].type = News::ItemType::null;
}
return JS_UNDEFINED;
}
@@ -440,7 +440,7 @@ namespace OpenRCT2::Scripting
assoc = JSToUint(ctx, subject);
}
}
News::AddItemToQueue(getGameState().park.newsItems, type, text.c_str(), assoc);
getGameState().park.newsItems.addItemToQueue(type, text.c_str(), assoc);
return JS_UNDEFINED;
}
@@ -23,13 +23,17 @@ namespace OpenRCT2::Scripting
News::Item* ScParkMessage::GetMessage(JSValue thisVal)
{
auto index = gScParkMessage.GetOpaque<OpaqueParkMessageData*>(thisVal)->index;
return &getGameState().park.newsItems[index];
if (index < News::kNewsQueueSize)
return &getGameState().park.newsItems.queue[index];
return &getGameState().park.newsItems.archive[index - News::kNewsQueueSize];
}
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::kNewsQueueSize);
}
JSValue ScParkMessage::month_get(JSContext* ctx, JSValue thisVal)
@@ -173,7 +177,12 @@ namespace OpenRCT2::Scripting
JSValue ScParkMessage::remove(JSContext* ctx, JSValue thisVal, int argc, JSValue* argv)
{
auto index = gScParkMessage.GetOpaque<OpaqueParkMessageData*>(thisVal)->index;
News::RemoveItem(getGameState().park.newsItems, static_cast<int32_t>(index));
if (index < News::kNewsQueueSize)
getGameState().park.newsItems.queue.remove(static_cast<int32_t>(index));
else
getGameState().park.newsItems.archive.remove(static_cast<int32_t>(index - News::kNewsQueueSize));
return JS_UNDEFINED;
}
@@ -208,7 +208,7 @@ namespace OpenRCT2::Scripting
JSValue result = JS_NewArray(ctx);
int32_t resultIndex = 0;
for (int32_t direction = 0; direction < 4; direction++)
for (Direction direction : kAllDirections)
{
if (!(edges & (1 << direction)))
continue;
@@ -207,6 +207,7 @@ namespace OpenRCT2::Scripting
JS_CGETSET_DEF("guests", ScScenarioObjective::guests_get, ScScenarioObjective::guests_set),
JS_CGETSET_DEF("year", ScScenarioObjective::year_get, ScScenarioObjective::year_set),
JS_CGETSET_DEF("excitement", ScScenarioObjective::excitement_get, ScScenarioObjective::excitement_set),
JS_CGETSET_DEF("length", ScScenarioObjective::length_get, ScScenarioObjective::length_set),
JS_CGETSET_DEF("monthlyIncome", ScScenarioObjective::monthlyIncome_get, ScScenarioObjective::monthlyIncome_set),
JS_CGETSET_DEF("parkValue", ScScenarioObjective::parkValue_get, ScScenarioObjective::parkValue_set),
};
+85
View File
@@ -0,0 +1,85 @@
/*****************************************************************************
* 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 <cstdint>
constexpr auto kNumOrthogonalDirections = 4;
/**
* Cardinal directions are represented by the Direction type. It has four
* possible values:
* 0 is X-decreasing (West)
* 1 is Y-increasing (North)
* 2 is X-increasing (East)
* 3 is Y-decreasing (South)
* Direction is not used to model up/down, or diagonal directions.
*/
using Direction = uint8_t;
const Direction kInvalidDirection = 0xFF;
/**
* Array of all valid cardinal directions, to make it easy to write range-based for loops like:
* for (Direction d : kAllDirections)
*/
constexpr Direction kAllDirections[] = {
0,
1,
2,
3,
};
/**
* Given a direction, return the direction that points the other way,
* on the same axis.
*/
inline constexpr Direction DirectionReverse(Direction dir)
{
return dir ^ 2;
}
inline constexpr bool DirectionValid(Direction dir)
{
return dir < kNumOrthogonalDirections;
}
/**
* Rotate a direction by the given number of 90-degree increments. Positive values
* rotate clockwise, negative values rotate counterclockwise.
*/
inline constexpr Direction DirectionRotate(Direction dir, int rotations)
{
return (dir + rotations) & 0x03;
}
/**
* Given a direction, return the next clockwise cardinal direction, wrapping around if necessary.
*/
inline constexpr Direction DirectionNext(Direction dir)
{
return DirectionRotate(dir, 1);
}
/**
* Given a direction, return the next counter-clockwise cardinal direction, wrapping around if necessary.
*/
inline constexpr Direction DirectionPrev(Direction dir)
{
return DirectionRotate(dir, -1);
}
/*
* Flips the X axis so 1 and 3 are swapped 0 and 2 will stay the same.
*/
inline constexpr Direction DirectionFlipXAxis(Direction direction)
{
return (direction * 3) % 4;
}
+2 -2
View File
@@ -123,7 +123,7 @@ money64 OpenRCT2::RideEntranceExitPlaceGhost(
*/
void MazeEntranceHedgeReplacement(const CoordsXYE& entrance)
{
int32_t direction = entrance.element->getDirection();
Direction direction = entrance.element->getDirection();
auto hedgePos = entrance + CoordsDirectionDelta[direction];
int32_t z = entrance.element->getBaseZ();
RideId rideIndex = entrance.element->asEntrance()->getRideIndex();
@@ -160,7 +160,7 @@ void MazeEntranceHedgeReplacement(const CoordsXYE& entrance)
*/
void MazeEntranceHedgeRemoval(const CoordsXYE& entrance)
{
int32_t direction = entrance.element->getDirection();
Direction direction = entrance.element->getDirection();
auto hedgePos = entrance + CoordsDirectionDelta[direction];
int32_t z = entrance.element->getBaseZ();
RideId rideIndex = entrance.element->asEntrance()->getRideIndex();
+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;
+5 -5
View File
@@ -219,9 +219,9 @@ namespace OpenRCT2
std::get<0>(tileElements) = { initialTileElement, footpathPos };
int32_t z = initialTileElement->getBaseZ();
for (int32_t initialDirection = 0; initialDirection < kNumOrthogonalDirections; initialDirection++)
for (Direction initialDirection : kAllDirections)
{
int32_t direction = initialDirection;
Direction direction = initialDirection;
auto currentPos = footpathPos + CoordsDirectionDelta[direction];
std::get<1>(tileElements) = {
@@ -1552,7 +1552,7 @@ namespace OpenRCT2
if (tileElement->asPath()->isQueue())
{
FootpathQueueChainPush(tileElement->asPath()->getRideIndex());
for (int32_t direction = 0; direction < kNumOrthogonalDirections; direction++)
for (Direction direction : kAllDirections)
{
if (tileElement->asPath()->getEdges() & (1 << direction))
{
@@ -1764,7 +1764,7 @@ namespace OpenRCT2
FootpathUpdateQueueEntranceBanner(footpathPos, tileElement);
for (uint8_t direction = 0; direction < kNumOrthogonalDirections; direction++)
for (Direction direction : kAllDirections)
{
int32_t z1 = tileElement->baseHeight;
if (tileElement->getType() == TileElementType::path)
@@ -1890,7 +1890,7 @@ namespace OpenRCT2
return ride->getRideTypeDescriptor().flags.has(RtdFlag::supportsLevelCrossings);
}
bool FootpathIsZAndDirectionValid(const PathElement& pathElement, int32_t currentZ, int32_t currentDirection)
bool FootpathIsZAndDirectionValid(const PathElement& pathElement, int32_t currentZ, Direction currentDirection)
{
if (pathElement.isSloped())
{
+1 -1
View File
@@ -200,7 +200,7 @@ namespace OpenRCT2
void FootpathQueueChainReset();
void FootpathQueueChainPush(RideId rideIndex);
int32_t FootpathQueueCountConnections(const CoordsXY& position, const PathElement& pathElement);
bool FootpathIsZAndDirectionValid(const PathElement& tileElement, int32_t currentZ, int32_t currentDirection);
bool FootpathIsZAndDirectionValid(const PathElement& tileElement, int32_t currentZ, Direction currentDirection);
FootpathPlacementResult FootpathGetOnTerrainPlacement(const TileCoordsXY& location);
FootpathPlacementResult FootpathGetOnTerrainPlacement(const SurfaceElement& surfaceElement);
+21 -86
View File
@@ -11,6 +11,7 @@
#include "../core/CoordsRange.hpp"
#include "../core/Numerics.hpp"
#include "../world/Direction.hpp"
#include "../world/MapLimits.h"
#include <cstdint>
@@ -18,8 +19,6 @@
constexpr int16_t kLocationNull = -32768;
constexpr int32_t kCoordsNull = 0xFFFF8000;
constexpr auto kNumOrthogonalDirections = 4;
/**
* Tile coordinates use 1 x/y increment per tile and 1 z increment per step.
* Regular ('big', 'sprite') coordinates use 32 x/y increments per tile and 8 z increments per step.
@@ -453,89 +452,6 @@ struct TileCoordsXYRangedZ : public TileCoordsXY
}
};
/**
* Cardinal directions are represented by the Direction type. It has four
* possible values:
* 0 is X-decreasing
* 1 is Y-increasing
* 2 is X-increasing
* 3 is Y-decreasing
* Direction is not used to model up/down, or diagonal directions.
*/
using Direction = uint8_t;
const Direction kInvalidDirection = 0xFF;
/**
* Array of all valid cardinal directions, to make it easy to write range-based for loops like:
* for (Direction d : kAllDirections)
*/
constexpr Direction kAllDirections[] = {
0,
1,
2,
3,
};
/**
* Given a direction, return the direction that points the other way,
* on the same axis.
*/
inline constexpr Direction DirectionReverse(Direction dir)
{
return dir ^ 2;
}
inline constexpr bool DirectionValid(Direction dir)
{
return dir < kNumOrthogonalDirections;
}
/**
* Given a direction, return the next cardinal direction, wrapping around if necessary.
* (TODO: Figure out if this is CW or CCW)
*/
inline constexpr Direction DirectionNext(Direction dir)
{
return (dir + 1) & 0x03;
}
/**
* Given a direction, return the previous cardinal direction, wrapping around if necessary.
* (TODO: Figure out if this is CW or CCW)
*/
inline constexpr Direction DirectionPrev(Direction dir)
{
return (dir - 1) & 0x03;
}
/**
* Given two positions, return the cardinal direction which is closest to the direction from 'from' to 'to'.
*/
inline constexpr Direction DirectionFromTo(const CoordsXY& from, const CoordsXY& to)
{
int16_t x_diff = to.x - from.x;
int16_t y_diff = to.y - from.y;
int16_t abs_x = x_diff < 0 ? -x_diff : x_diff;
int16_t abs_y = y_diff < 0 ? -y_diff : y_diff;
if (abs_x <= abs_y)
{
return y_diff < 0 ? 3 : 1;
}
return x_diff < 0 ? 0 : 2;
}
/*
* Flips the X axis so 1 and 3 are swapped 0 and 2 will stay the same.
*/
inline constexpr Direction DirectionFlipXAxis(Direction direction)
{
return (direction * 3) % 4;
}
struct CoordsXYZD : public CoordsXYZ
{
Direction direction{};
@@ -605,7 +521,7 @@ struct CoordsXYZD : public CoordsXYZ
constexpr CoordsXYZD toTileCentre() const
{
return toTileStart() + CoordsXYZD{ kCoordsXYHalfTile, kCoordsXYHalfTile, 0, 0 };
return toTileStart() + CoordsXY{ kCoordsXYHalfTile, kCoordsXYHalfTile };
}
};
@@ -668,6 +584,25 @@ struct TileCoordsXYZD : public TileCoordsXYZ
}
};
/**
* Given two positions, return the cardinal direction which is closest to the direction from 'from' to 'to'.
*/
inline constexpr Direction DirectionFromTo(const CoordsXY& from, const CoordsXY& to)
{
int16_t x_diff = to.x - from.x;
int16_t y_diff = to.y - from.y;
int16_t abs_x = x_diff < 0 ? -x_diff : x_diff;
int16_t abs_y = y_diff < 0 ? -y_diff : y_diff;
if (abs_x <= abs_y)
{
return y_diff < 0 ? 3 : 1;
}
return x_diff < 0 ? 0 : 2;
}
/**
* Represents a rectangular range of the map using regular coordinates (32 per tile).
*/
+3 -3
View File
@@ -418,7 +418,7 @@ namespace OpenRCT2
return nullptr;
}
BannerElement* MapGetBannerElementAt(const CoordsXYZ& bannerPos, uint8_t position)
BannerElement* MapGetBannerElementAt(const CoordsXYZ& bannerPos, Direction position)
{
const auto bannerTilePos = TileCoordsXYZ{ bannerPos };
for (auto* element : TileElementsView<BannerElement>(bannerPos))
@@ -688,7 +688,7 @@ namespace OpenRCT2
* Checks if the tile at coordinate at height counts as connected.
* @return 1 if connected, 0 otherwise
*/
bool MapCoordIsConnected(const TileCoordsXYZ& loc, uint8_t faceDirection)
bool MapCoordIsConnected(const TileCoordsXYZ& loc, Direction faceDirection)
{
TileElement* tileElement = MapGetFirstElementAt(loc);
@@ -700,7 +700,7 @@ namespace OpenRCT2
if (tileElement->getType() != TileElementType::path)
continue;
uint8_t slopeDirection = tileElement->asPath()->getSlopeDirection();
Direction slopeDirection = tileElement->asPath()->getSlopeDirection();
if (tileElement->asPath()->isSloped())
{
+2 -2
View File
@@ -74,7 +74,7 @@ namespace OpenRCT2
TileElement* MapGetFirstTileElementWithBaseHeightBetween(const TileCoordsXYRangedZ& loc, TileElementType type);
void MapSetTileElement(const TileCoordsXY& tilePos, TileElement* elements);
int32_t MapHeightFromSlope(const CoordsXY& coords, int32_t slopeDirection, bool isSloped);
BannerElement* MapGetBannerElementAt(const CoordsXYZ& bannerPos, uint8_t position);
BannerElement* MapGetBannerElementAt(const CoordsXYZ& bannerPos, Direction position);
SurfaceElement* MapGetSurfaceElementAt(const TileCoordsXY& coords);
SurfaceElement* MapGetSurfaceElementAt(const CoordsXY& coords);
PathElement* MapGetPathElementAt(const TileCoordsXYZ& loc);
@@ -86,7 +86,7 @@ namespace OpenRCT2
EntranceElement* MapGetRideExitElementAt(const CoordsXYZ& exitCoords, bool ghost);
uint8_t MapGetHighestLandHeight(const MapRange& range);
uint8_t MapGetLowestLandHeight(const MapRange& range);
bool MapCoordIsConnected(const TileCoordsXYZ& loc, uint8_t faceDirection);
bool MapCoordIsConnected(const TileCoordsXYZ& loc, Direction faceDirection);
void MapUpdatePathWideFlags();
bool MapIsLocationValid(const CoordsXY& coords);
bool MapIsEdge(const CoordsXY& coords);
+1 -1
View File
@@ -166,7 +166,7 @@ static std::optional<UpdateType> UpdateSmallSceneryAnimation(
// Don't apply anything to peeps when the scenery is a ghost.
if (!scenery.isGhost() && !(getGameState().currentTicks & 0x3FF))
{
const int32_t direction = scenery.getDirection();
const Direction direction = scenery.getDirection();
auto quad = EntityTileList<Peep>(CoordsXY{ loc.x, loc.y } - CoordsDirectionDelta[direction]);
for (auto peep : quad)
{
+1 -1
View File
@@ -132,6 +132,6 @@ namespace OpenRCT2::Park
std::vector<Award> currentAwards;
std::vector<MarketingCampaign> marketingCampaigns;
News::ItemQueues newsItems;
News::Items newsItems;
};
} // namespace OpenRCT2::Park
+1 -1
View File
@@ -13,7 +13,7 @@
#include "Location.hpp"
// Rotate both of the values amount
const QuarterTile QuarterTile::Rotate(uint8_t amount) const
const QuarterTile QuarterTile::Rotate(Direction amount) const
{
switch (amount)
{
+2 -1
View File
@@ -11,6 +11,7 @@
#include <cstdint>
using Direction = uint8_t;
struct TileCornersZ;
class QuarterTile
@@ -30,7 +31,7 @@ public:
}
// Rotate both of the values amount. Returns new RValue QuarterTile
const QuarterTile Rotate(uint8_t amount) const;
const QuarterTile Rotate(Direction amount) const;
uint8_t GetBaseQuarterOccupied() const;
uint8_t GetZQuarterOccupied() const;
TileCornersZ GetQuarterHeights(int32_t height) const;
+1 -1
View File
@@ -219,7 +219,7 @@ namespace OpenRCT2::TileInspector
case TileElementType::path:
if (tileElement->asPath()->isSloped())
{
newRotation = (tileElement->asPath()->getSlopeDirection() + 1) & kTileElementDirectionMask;
newRotation = DirectionNext(tileElement->asPath()->getSlopeDirection());
tileElement->asPath()->setSlopeDirection(newRotation);
}
pathEdges = tileElement->asPath()->getEdges();
+1 -1
View File
@@ -121,7 +121,7 @@ uint8_t GetWallSlopeFromEdgeSlope(uint8_t Slope, uint8_t Edge)
*
* rct2: 0x006E59DC
*/
bool WallInTheWay(const CoordsXYRangedZ& fencePos, int32_t direction)
bool WallInTheWay(const CoordsXYRangedZ& fencePos, Direction direction)
{
TileElement* tileElement = MapGetFirstElementAt(fencePos);
if (tileElement == nullptr)
+1 -1
View File
@@ -31,4 +31,4 @@ void WallRemoveIntersectingWalls(const CoordsXYRangedZ& wallPos, Direction direc
uint8_t GetWallSlopeFromEdgeSlope(uint8_t Slope, uint8_t Edge);
bool WallInTheWay(const CoordsXYRangedZ& fencePos, int32_t direction);
bool WallInTheWay(const CoordsXYRangedZ& fencePos, Direction direction);
@@ -31,12 +31,12 @@ namespace OpenRCT2
index = newIndex;
}
uint8_t BannerElement::getPosition() const
Direction BannerElement::getPosition() const
{
return position;
}
void BannerElement::setPosition(uint8_t newPosition)
void BannerElement::setPosition(Direction newPosition)
{
position = newPosition;
}
@@ -23,7 +23,7 @@ namespace OpenRCT2
private:
BannerIndex index; // 5
uint8_t position; // 7
Direction position; // 7
uint8_t allowedEdges; // 8
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
@@ -36,8 +36,8 @@ namespace OpenRCT2
BannerIndex getIndex() const;
void setIndex(BannerIndex newIndex);
uint8_t getPosition() const;
void setPosition(uint8_t newPosition);
Direction getPosition() const;
void setPosition(Direction newPosition);
uint8_t getAllowedEdges() const;
void setAllowedEdges(uint8_t newEdges);
@@ -62,7 +62,7 @@ namespace OpenRCT2
uint8_t additions; // 9 (0 means no addition)
uint8_t edgesAndCorners; // 10 (edges in lower 4 bits, corners in upper 4)
FootpathElementFlags flags2; // 11
uint8_t slopeDirection; // 12
Direction slopeDirection; // 12
union
{
uint8_t additionStatus; // 13, only used for litter bins
@@ -47,7 +47,7 @@ namespace OpenRCT2
Direction TileElementBase::getDirectionWithOffset(uint8_t offset) const
{
return ((this->type & kTileElementDirectionMask) + offset) & kTileElementDirectionMask;
return DirectionRotate(getDirection(), offset);
}
bool TileElementBase::isLastForTile() const
+17
View File
@@ -73,4 +73,21 @@ TEST_F(ScriptingTests, MultipleSubscribersToSameEventShouldNotCrash)
hookEngine.Call(HookType::intervalTick, arg, false);
}
TEST(ScriptEngineLifetimeTests, UninitialisedContextCanBeDestroyedAfterInitialisedOne)
{
gOpenRCT2Headless = true;
gOpenRCT2NoGraphics = true;
// Registers the global script classes and then frees the JS runtime they belong to.
{
auto context = CreateContext();
context->GetScriptEngine().Initialise();
}
// Unregisters the global script classes again without registering them first.
{
auto context = CreateContext();
}
}
#endif