Skip to content

Commit

Permalink
Revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry-Hopkinson committed Mar 27, 2024
1 parent edad174 commit 691933a
Show file tree
Hide file tree
Showing 43 changed files with 223 additions and 364 deletions.
Empty file modified src/openrct2-android/gradlew
100755 → 100644
Empty file.
23 changes: 22 additions & 1 deletion src/openrct2-ui/windows/EditorBottomToolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,30 @@ static Widget _editorBottomToolbarWidgets[] = {
GfxInvalidateScreen();
}

bool CheckObjectSelection() const
{
WindowBase* w;

auto [missingObjectType, errorString] = Editor::CheckObjectSelection();
if (missingObjectType == ObjectType::None)
{
WindowCloseByClass(WindowClass::EditorObjectSelection);
return true;
}

ContextShowError(STR_INVALID_SELECTION_OF_OBJECTS, errorString, {});
w = WindowFindByClass(WindowClass::EditorObjectSelection);
if (w != nullptr)
{
// Click tab with missing object
w->OnMouseUp(WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 + EnumValue(missingObjectType));
}
return false;
}

void JumpForwardFromObjectSelection() const
{
if (!EditorObjectSelectionWindowCheck())
if (!CheckObjectSelection())
return;

FinishObjectSelection();
Expand Down
37 changes: 1 addition & 36 deletions src/openrct2-ui/windows/EditorObjectSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,7 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
switch (widgetIndex)
{
case WIDX_CLOSE:
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) && !EditorObjectSelectionWindowCheck())
return;

WindowClose(*this);
if (gScreenFlags & SCREEN_FLAGS_EDITOR)
{
FinishObjectSelection();
Expand Down Expand Up @@ -1110,18 +1108,6 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
DrawDebugData(dpi);
}

void GoToTab(ObjectType objectType)
{
for (size_t offset = 0; offset < std::size(TabOrder); offset++)
{
if (TabOrder[offset] == objectType)
{
SetPage(static_cast<int32_t>(offset));
return;
}
}
}

private:
void InitWidgets()
{
Expand Down Expand Up @@ -1674,25 +1660,4 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
if (showFallbackWarning)
ContextShowError(STR_OBJECT_SELECTION_FALLBACK_IMAGES_WARNING, STR_EMPTY, Formatter::Common());
}

bool EditorObjectSelectionWindowCheck()
{
WindowBase* w;

auto [missingObjectType, errorString] = Editor::CheckObjectSelection();
if (missingObjectType == ObjectType::None)
{
WindowCloseByClass(WindowClass::EditorObjectSelection);
return true;
}

ContextShowError(STR_INVALID_SELECTION_OF_OBJECTS, errorString, {});
w = WindowFindByClass(WindowClass::EditorObjectSelection);
if (w != nullptr)
{
// Click tab with missing object
static_cast<EditorObjectSelectionWindow*>(w)->GoToTab(missingObjectType);
}
return false;
}
} // namespace OpenRCT2::Ui::Windows
23 changes: 11 additions & 12 deletions src/openrct2-ui/windows/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace OpenRCT2::Ui::Windows
return MapColour2((colour & 0xFF00) >> 8, PALETTE_INDEX_10);
}

constexpr int32_t MAP_WINDOW_MAP_SIZE = kMaximumMapSizeTechnical * 2;
constexpr int32_t MAP_WINDOW_MAP_SIZE = MAXIMUM_MAP_SIZE_TECHNICAL * 2;

static constexpr StringId WINDOW_TITLE = STR_MAP_LABEL;
static constexpr int32_t WH = 259;
Expand Down Expand Up @@ -131,10 +131,10 @@ static Widget window_map_widgets[] = {
// used in transforming viewport view coordinates to minimap coordinates
// rct2: 0x00981BBC
static constexpr ScreenCoordsXY MiniMapOffsets[] = {
{ kMaximumMapSizeTechnical - 8, 0 },
{ 2 * kMaximumMapSizeTechnical - 8, kMaximumMapSizeTechnical },
{ kMaximumMapSizeTechnical - 8, 2 * kMaximumMapSizeTechnical },
{ 0 - 8, kMaximumMapSizeTechnical },
{ MAXIMUM_MAP_SIZE_TECHNICAL - 8, 0 },
{ 2 * MAXIMUM_MAP_SIZE_TECHNICAL - 8, MAXIMUM_MAP_SIZE_TECHNICAL },
{ MAXIMUM_MAP_SIZE_TECHNICAL - 8, 2 * MAXIMUM_MAP_SIZE_TECHNICAL },
{ 0 - 8, MAXIMUM_MAP_SIZE_TECHNICAL },
};
// clang-format on

Expand Down Expand Up @@ -691,8 +691,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
{
// The practical size is 2 lower than the technical size
size += 2;
size = std::clamp(
size, static_cast<int>(kMinimumMapSizeTechnical), static_cast<int>(kMaximumMapSizeTechnical));
size = std::clamp(size, MINIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL);

TileCoordsXY newMapSize = GetGameState().MapSize;
if (_resizeDirection != ResizeDirection::X)
Expand Down Expand Up @@ -1070,7 +1069,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
{
int32_t x = 0, y = 0, dx = 0, dy = 0;

int32_t pos = (_currentLine * (MAP_WINDOW_MAP_SIZE - 1)) + kMaximumMapSizeTechnical - 1;
int32_t pos = (_currentLine * (MAP_WINDOW_MAP_SIZE - 1)) + MAXIMUM_MAP_SIZE_TECHNICAL - 1;
auto destinationPosition = ScreenCoordsXY{ pos % MAP_WINDOW_MAP_SIZE, pos / MAP_WINDOW_MAP_SIZE };
auto destination = _mapImageData.data() + (destinationPosition.y * MAP_WINDOW_MAP_SIZE) + destinationPosition.x;
switch (GetCurrentRotation())
Expand Down Expand Up @@ -1101,7 +1100,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
break;
}

for (int32_t i = 0; i < kMaximumMapSizeTechnical; i++)
for (int32_t i = 0; i < MAXIMUM_MAP_SIZE_TECHNICAL; i++)
{
if (!MapIsEdge({ x, y }))
{
Expand All @@ -1126,7 +1125,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
destination = _mapImageData.data() + (destinationPosition.y * MAP_WINDOW_MAP_SIZE) + destinationPosition.x;
}
_currentLine++;
if (_currentLine >= kMaximumMapSizeTechnical)
if (_currentLine >= MAXIMUM_MAP_SIZE_TECHNICAL)
_currentLine = 0;
}

Expand Down Expand Up @@ -1415,7 +1414,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {

CoordsXY ScreenToMap(ScreenCoordsXY screenCoords)
{
screenCoords.x = ((screenCoords.x + 8) - kMaximumMapSizeTechnical) / 2;
screenCoords.x = ((screenCoords.x + 8) - MAXIMUM_MAP_SIZE_TECHNICAL) / 2;
screenCoords.y = ((screenCoords.y + 8)) / 2;
auto location = TileCoordsXY(screenCoords.y - screenCoords.x, screenCoords.x + screenCoords.y).ToCoordsXY();

Expand Down Expand Up @@ -1458,7 +1457,7 @@ static constexpr ScreenCoordsXY MiniMapOffsets[] = {
x /= 32;
y /= 32;

return { -x + y + kMaximumMapSizeTechnical - 8, x + y - 8 };
return { -x + y + MAXIMUM_MAP_SIZE_TECHNICAL - 8, x + y - 8 };
}

void ResizeMap()
Expand Down
8 changes: 2 additions & 6 deletions src/openrct2-ui/windows/MapGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,9 @@ static uint64_t PressedWidgets[WINDOW_MAPGEN_PAGE_COUNT] = {
_resizeDirection = ResizeDirection::Both;

if (_resizeDirection != ResizeDirection::X)
_mapSize.y = std::clamp(
_mapSize.y + sizeOffset, static_cast<int>(kMinimumMapSizeTechnical),
static_cast<int>(kMaximumMapSizeTechnical));
_mapSize.y = std::clamp(_mapSize.y + sizeOffset, MINIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL);
if (_resizeDirection != ResizeDirection::Y)
_mapSize.x = std::clamp(
_mapSize.x + sizeOffset, static_cast<int>(kMinimumMapSizeTechnical),
static_cast<int>(kMaximumMapSizeTechnical));
_mapSize.x = std::clamp(_mapSize.x + sizeOffset, MINIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL);
}

void InputMapSize(WidgetIndex callingWidget, int32_t currentValue)
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2-ui/windows/Park.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ static constexpr WindowParkAward _parkAwards[] = {
// Graph
screenPos = windowPos + ScreenCoordsXY{ widget->left + 47, widget->top + 26 };

Graph::Draw(dpi, GetGameState().ParkRatingHistory, kParkRatingHistorySize, screenPos);
Graph::Draw(dpi, GetGameState().ParkRatingHistory, 32, screenPos);
}

#pragma endregion
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2-ui/windows/RideConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,7 @@ static Widget _rideConstructionWidgets[] = {
auto& gameState = OpenRCT2::GetGameState();
auto preserveMapSize = gameState.MapSize;

gameState.MapSize = { kMaximumMapSizeTechnical, kMaximumMapSizeTechnical };
gameState.MapSize = { MAXIMUM_MAP_SIZE_TECHNICAL, MAXIMUM_MAP_SIZE_TECHNICAL };

// Setup non changing parts of the temporary track tile element
tempTrackTileElement.SetType(TileElementType::Track);
Expand Down
10 changes: 6 additions & 4 deletions src/openrct2-ui/windows/TileInspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@ static uint64_t PageDisabledWidgets[] = {
switch (widgetIndex)
{
case WIDX_SPINNER_X_INCREASE:
windowTileInspectorTile.x = std::min<int32_t>(windowTileInspectorTile.x + 1, kMaximumMapSizeTechnical - 1);
windowTileInspectorTile.x = std::min<int32_t>(
windowTileInspectorTile.x + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
_toolMap.x = std::min<int32_t>(_toolMap.x + 32, MAXIMUM_TILE_START_XY);
LoadTile(nullptr);
break;
Expand All @@ -753,7 +754,8 @@ static uint64_t PageDisabledWidgets[] = {
break;

case WIDX_SPINNER_Y_INCREASE:
windowTileInspectorTile.y = std::min<int32_t>(windowTileInspectorTile.y + 1, kMaximumMapSizeTechnical - 1);
windowTileInspectorTile.y = std::min<int32_t>(
windowTileInspectorTile.y + 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1);
_toolMap.y = std::min<int32_t>(_toolMap.y + 32, MAXIMUM_TILE_START_XY);
LoadTile(nullptr);
break;
Expand Down Expand Up @@ -2073,10 +2075,10 @@ static uint64_t PageDisabledWidgets[] = {
}
// X and Y spinners
SetWidgetDisabledAndInvalidate(
WIDX_SPINNER_X_INCREASE, !(_tileSelected && ((_toolMap.x / 32) < kMaximumMapSizeTechnical - 1)));
WIDX_SPINNER_X_INCREASE, !(_tileSelected && ((_toolMap.x / 32) < MAXIMUM_MAP_SIZE_TECHNICAL - 1)));
SetWidgetDisabledAndInvalidate(WIDX_SPINNER_X_DECREASE, !(_tileSelected && ((_toolMap.x / 32) > 0)));
SetWidgetDisabledAndInvalidate(
WIDX_SPINNER_Y_INCREASE, !(_tileSelected && ((_toolMap.y / 32) < kMaximumMapSizeTechnical - 1)));
WIDX_SPINNER_Y_INCREASE, !(_tileSelected && ((_toolMap.y / 32) < MAXIMUM_MAP_SIZE_TECHNICAL - 1)));
SetWidgetDisabledAndInvalidate(WIDX_SPINNER_Y_DECREASE, !(_tileSelected && ((_toolMap.y / 32) > 0)));

// Sort buttons
Expand Down
1 change: 0 additions & 1 deletion src/openrct2-ui/windows/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ namespace OpenRCT2::Ui::Windows
void WindowTileInspectorClearClipboard();

WindowBase* EditorObjectSelectionOpen();
bool EditorObjectSelectionWindowCheck();

void WindowTooltipReset(const ScreenCoordsXY& screenCoords);
void WindowTooltipShow(const OpenRCT2String& message, ScreenCoordsXY screenCoords);
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ static void FixInvalidSurfaces()
// Fixes broken saves where a surface element could be null
// and broken saves with incorrect invisible map border tiles

for (int32_t y = 0; y < kMaximumMapSizeTechnical; y++)
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
{
for (int32_t x = 0; x < kMaximumMapSizeTechnical; x++)
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
{
auto* surfaceElement = MapGetSurfaceElementAt(TileCoordsXY{ x, y });

Expand Down
3 changes: 1 addition & 2 deletions src/openrct2/GameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "world/Banner.h"
#include "world/Climate.h"
#include "world/Location.hpp"
#include "world/Park.h"

#include <array>
#include <chrono>
Expand Down Expand Up @@ -53,7 +52,7 @@ namespace OpenRCT2
money64 ConstructionRightsPrice;
money64 CurrentExpenditure;
money64 CurrentProfit;
uint8_t ParkRatingHistory[kParkRatingHistorySize];
uint8_t ParkRatingHistory[32];
uint32_t GuestsInParkHistory[32];
ClimateType Climate;
ClimateState ClimateCurrent;
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/actions/FootpathLayoutPlaceAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ GameActions::Result FootpathLayoutPlaceAction::ElementInsertQuery(GameActions::R
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
zHigh += PATH_HEIGHT_STEP;
}

Expand Down Expand Up @@ -205,7 +205,7 @@ GameActions::Result FootpathLayoutPlaceAction::ElementInsertExecute(GameActions:
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
zHigh += PATH_HEIGHT_STEP;
}

Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/actions/FootpathPlaceAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ GameActions::Result FootpathPlaceAction::ElementInsertQuery(GameActions::Result
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
zHigh += PATH_HEIGHT_STEP;
}

Expand Down Expand Up @@ -351,7 +351,7 @@ GameActions::Result FootpathPlaceAction::ElementInsertExecute(GameActions::Resul
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & kTileElementDirectionMask);
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
zHigh += PATH_HEIGHT_STEP;
}

Expand Down
4 changes: 2 additions & 2 deletions src/openrct2/actions/MapChangeSizeAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ void MapChangeSizeAction::Serialise(DataSerialiser& stream)

GameActions::Result MapChangeSizeAction::Query() const
{
if (_targetSize.x > kMaximumMapSizeTechnical || _targetSize.y > kMaximumMapSizeTechnical)
if (_targetSize.x > MAXIMUM_MAP_SIZE_TECHNICAL || _targetSize.y > MAXIMUM_MAP_SIZE_TECHNICAL)
{
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_INCREASE_MAP_SIZE_ANY_FURTHER, STR_NONE);
}
if (_targetSize.x < kMinimumMapSizeTechnical || _targetSize.y < kMinimumMapSizeTechnical)
if (_targetSize.x < MINIMUM_MAP_SIZE_TECHNICAL || _targetSize.y < MINIMUM_MAP_SIZE_TECHNICAL)
{
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_DECREASE_MAP_SIZE_ANY_FURTHER, STR_NONE);
}
Expand Down
6 changes: 3 additions & 3 deletions src/openrct2/actions/WallPlaceAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ bool WallPlaceAction::WallCheckObstructionWithTrack(
using namespace OpenRCT2::TrackMetaData;
const auto& ted = GetTrackElementDescriptor(trackType);
int32_t sequence = trackElement->GetSequenceIndex();
int32_t direction = (_edge - trackElement->GetDirection()) & kTileElementDirectionMask;
int32_t direction = (_edge - trackElement->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK;
auto ride = GetRide(trackElement->GetRideIndex());
if (ride == nullptr)
{
Expand Down Expand Up @@ -484,7 +484,7 @@ bool WallPlaceAction::WallCheckObstructionWithTrack(
return false;
}

direction = (trackElement->GetDirection() + ted.Coordinates.rotation_end) & kTileElementDirectionMask;
direction = (trackElement->GetDirection() + ted.Coordinates.rotation_end) & TILE_ELEMENT_DIRECTION_MASK;
if (direction != _edge)
{
return false;
Expand Down Expand Up @@ -561,7 +561,7 @@ GameActions::Result WallPlaceAction::WallCheckObstruction(
auto sequence = largeSceneryElement->GetSequenceIndex();
const LargeSceneryTile& tile = sceneryEntry->tiles[sequence];

int32_t direction = ((_edge - tileElement->GetDirection()) & kTileElementDirectionMask) + 8;
int32_t direction = ((_edge - tileElement->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK) + 8;
if (!(tile.flags & (1 << direction)))
{
MapGetObstructionErrorText(tileElement, res);
Expand Down
6 changes: 3 additions & 3 deletions src/openrct2/entity/EntityRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static std::vector<EntityId> _freeIdList;

static bool _entityFlashingList[MAX_ENTITIES];

constexpr const uint32_t SPATIAL_INDEX_SIZE = (kMaximumMapSizeTechnical * kMaximumMapSizeTechnical) + 1;
constexpr const uint32_t SPATIAL_INDEX_SIZE = (MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL) + 1;
constexpr uint32_t SPATIAL_INDEX_LOCATION_NULL = SPATIAL_INDEX_SIZE - 1;

static std::array<std::vector<EntityId>, SPATIAL_INDEX_SIZE> gEntitySpatialIndex;
Expand All @@ -60,10 +60,10 @@ static constexpr size_t GetSpatialIndexOffset(const CoordsXY& loc)
const auto tileX = std::abs(loc.x) / COORDS_XY_STEP;
const auto tileY = std::abs(loc.y) / COORDS_XY_STEP;

if (tileX >= kMaximumMapSizeTechnical || tileY >= kMaximumMapSizeTechnical)
if (tileX >= MAXIMUM_MAP_SIZE_TECHNICAL || tileY >= MAXIMUM_MAP_SIZE_TECHNICAL)
return SPATIAL_INDEX_LOCATION_NULL;

return tileX * kMaximumMapSizeTechnical + tileY;
return tileX * MAXIMUM_MAP_SIZE_TECHNICAL + tileY;
}

constexpr bool EntityTypeIsMiscEntity(const EntityType type)
Expand Down

0 comments on commit 691933a

Please sign in to comment.