1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

More code review changes

This commit is contained in:
Ted John
2022-02-03 22:12:00 +00:00
parent 454bfb0a8f
commit 3d2420c86c
10 changed files with 26 additions and 27 deletions

View File

@@ -502,7 +502,7 @@ namespace OpenRCT2
viewport_init_all();
_gameState = std::make_unique<GameState>();
_gameState->InitAll({ 150, 150 });
_gameState->InitAll(DEFAULT_MAP_SIZE);
_titleScreen = std::make_unique<TitleScreen>(*_gameState);
_uiContext->Initialise();

View File

@@ -206,7 +206,8 @@ namespace Editor
*/
static void SetAllLandOwned()
{
MapRange range = { 64, 64, (gMapSize.x - 3) * 32, (gMapSize.y - 3) * 32 };
MapRange range = { 2 * COORDS_XY_STEP, 2 * COORDS_XY_STEP, (gMapSize.x - 3) * COORDS_XY_STEP,
(gMapSize.y - 3) * COORDS_XY_STEP };
auto landSetRightsAction = LandSetRightsAction(range, LandSetRightSetting::SetForSale);
landSetRightsAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND);
GameActions::Execute(&landSetRightsAction);

View File

@@ -15,7 +15,7 @@
#include "../ui/WindowManager.h"
#include "../windows/Intent.h"
ChangeMapSizeAction::ChangeMapSizeAction(const TileCoordsXY targetSize)
ChangeMapSizeAction::ChangeMapSizeAction(const TileCoordsXY& targetSize)
: _targetSize(targetSize)
{
}
@@ -37,7 +37,7 @@ GameActions::Result ChangeMapSizeAction::Query() const
{
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_INCREASE_MAP_SIZE_ANY_FURTHER, STR_NONE);
}
if (_targetSize.x < 16 || _targetSize.y < 16)
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);
}

View File

@@ -16,7 +16,7 @@ class ChangeMapSizeAction final : public GameActionBase<GameCommand::ChangeMapSi
{
public:
ChangeMapSizeAction() = default;
ChangeMapSizeAction(const TileCoordsXY targetSize);
ChangeMapSizeAction(const TileCoordsXY& targetSize);
void AcceptParameters(GameActionParameterVisitor& visitor) override;
uint16_t GetActionFlags() const override;

View File

@@ -458,16 +458,16 @@ void FootpathPlaceAction::AutomaticallySetPeepSpawn() const
{
auto mapSizeUnits = GetMapSizeUnits();
uint8_t direction = 0;
if (_loc.x != 32)
if (_loc.x != COORDS_XY_STEP)
{
direction++;
if (_loc.y != mapSizeUnits.y - 32)
if (_loc.y != mapSizeUnits.y - COORDS_XY_STEP)
{
direction++;
if (_loc.x != mapSizeUnits.x - 32)
if (_loc.x != mapSizeUnits.x - COORDS_XY_STEP)
{
direction++;
if (_loc.y != 32)
if (_loc.y != COORDS_XY_STEP)
return;
}
}

View File

@@ -51,8 +51,9 @@ GameActions::Result PlaceParkEntranceAction::Query() const
res.Expenditure = ExpenditureType::LandPurchase;
res.Position = { _loc.x, _loc.y, _loc.z };
auto mapSizeUnits = GetMapSizeUnits() - CoordsXY{ 32, 32 };
if (!LocationValid(_loc) || _loc.x <= 32 || _loc.y <= 32 || _loc.x >= mapSizeUnits.x || _loc.y >= mapSizeUnits.y)
auto mapSizeUnits = GetMapSizeUnits() - CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP };
if (!LocationValid(_loc) || _loc.x <= COORDS_XY_STEP || _loc.y <= COORDS_XY_STEP || _loc.x >= mapSizeUnits.x
|| _loc.y >= mapSizeUnits.y)
{
return GameActions::Result(
GameActions::Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_TOO_CLOSE_TO_EDGE_OF_MAP);

View File

@@ -683,8 +683,8 @@ void SetCheatAction::SetStaffSpeed(uint8_t value) const
void SetCheatAction::OwnAllLand() const
{
const auto min = CoordsXY{ 32, 32 };
const auto max = GetMapSizeUnits() - CoordsXY{ 32, 32 };
const auto min = CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP };
const auto max = GetMapSizeUnits() - CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP };
for (CoordsXY coords = min; coords.y <= max.y; coords.y += COORDS_XY_STEP)
{

View File

@@ -87,8 +87,8 @@ static std::vector<RecordedPaintSession> extract_paint_session(std::string_view
gIntroState = IntroState::None;
gScreenFlags = SCREEN_FLAGS_PLAYING;
int32_t resolutionWidth = (gMapSize.x * 32 * 2);
int32_t resolutionHeight = (gMapSize.y * 32 * 1);
int32_t resolutionWidth = (gMapSize.x * COORDS_XY_STEP * 2);
int32_t resolutionHeight = (gMapSize.y * COORDS_XY_STEP * 1);
resolutionWidth += 8;
resolutionHeight += 128;
@@ -102,15 +102,11 @@ static std::vector<RecordedPaintSession> extract_paint_session(std::string_view
viewport.var_11 = 0;
viewport.flags = 0;
int32_t customX = (gMapSize.x / 2) * 32 + 16;
int32_t customY = (gMapSize.y / 2) * 32 + 16;
auto customXY = TileCoordsXY(gMapSize.x / 2, gMapSize.y / 2).ToCoordsXY().ToTileCentre();
auto customXYZ = CoordsXYZ(customXY, tile_element_height(customXY));
auto screenXY = translate_3d_to_2d_with_z(0, customXYZ);
int32_t x = 0, y = 0;
int32_t z = tile_element_height({ customX, customY });
x = customY - customX;
y = ((customX + customY) / 2) - z;
viewport.viewPos = { x - ((viewport.view_width) / 2), y - ((viewport.view_height) / 2) };
viewport.viewPos = { screenXY.x - (viewport.view_width / 2), screenXY.y - (viewport.view_height / 2) };
viewport.zoom = ZoomLevel{ 0 };
gCurrentRotation = 0;

View File

@@ -217,8 +217,8 @@ enum class EdgeType
static CoordsXY GetEdgeTile(TileCoordsXY mapSize, int32_t rotation, EdgeType edgeType, bool visible)
{
// TODO
int32_t lower = (visible ? 1 : 0) * 32;
int32_t upper = (visible ? mapSize.x - 2 : mapSize.x - 1) * 32;
int32_t lower = (visible ? 1 : 0) * COORDS_XY_STEP;
int32_t upper = (visible ? mapSize.x - 2 : mapSize.x - 1) * COORDS_XY_STEP;
switch (edgeType)
{
default:
@@ -688,8 +688,8 @@ int32_t cmdline_for_screenshot(const char** argv, int32_t argc, ScreenshotOption
const auto& mapSize = gMapSize;
if (resolutionWidth == 0 || resolutionHeight == 0)
{
resolutionWidth = (mapSize.x * 32 * 2) >> customZoom;
resolutionHeight = (mapSize.y * 32 * 1) >> customZoom;
resolutionWidth = (mapSize.x * COORDS_XY_STEP * 2) >> customZoom;
resolutionHeight = (mapSize.y * COORDS_XY_STEP * 1) >> customZoom;
resolutionWidth += 8;
resolutionHeight += 128;

View File

@@ -29,6 +29,7 @@ constexpr const int32_t MAXIMUM_MAP_SIZE_BIG = COORDS_XY_STEP * MAXIMUM_MAP_SIZE
constexpr const int32_t MAXIMUM_TILE_START_XY = MAXIMUM_MAP_SIZE_BIG - COORDS_XY_STEP;
constexpr const int32_t LAND_HEIGHT_STEP = 2 * COORDS_Z_STEP;
constexpr const int32_t MINIMUM_LAND_HEIGHT_BIG = MINIMUM_LAND_HEIGHT * COORDS_Z_STEP;
constexpr const TileCoordsXY DEFAULT_MAP_SIZE = { 150, 150 };
#define MAP_MINIMUM_X_Y (-MAXIMUM_MAP_SIZE_TECHNICAL)