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:
@@ -502,7 +502,7 @@ namespace OpenRCT2
|
|||||||
viewport_init_all();
|
viewport_init_all();
|
||||||
|
|
||||||
_gameState = std::make_unique<GameState>();
|
_gameState = std::make_unique<GameState>();
|
||||||
_gameState->InitAll({ 150, 150 });
|
_gameState->InitAll(DEFAULT_MAP_SIZE);
|
||||||
|
|
||||||
_titleScreen = std::make_unique<TitleScreen>(*_gameState);
|
_titleScreen = std::make_unique<TitleScreen>(*_gameState);
|
||||||
_uiContext->Initialise();
|
_uiContext->Initialise();
|
||||||
|
|||||||
@@ -206,7 +206,8 @@ namespace Editor
|
|||||||
*/
|
*/
|
||||||
static void SetAllLandOwned()
|
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);
|
auto landSetRightsAction = LandSetRightsAction(range, LandSetRightSetting::SetForSale);
|
||||||
landSetRightsAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND);
|
landSetRightsAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND);
|
||||||
GameActions::Execute(&landSetRightsAction);
|
GameActions::Execute(&landSetRightsAction);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include "../ui/WindowManager.h"
|
#include "../ui/WindowManager.h"
|
||||||
#include "../windows/Intent.h"
|
#include "../windows/Intent.h"
|
||||||
|
|
||||||
ChangeMapSizeAction::ChangeMapSizeAction(const TileCoordsXY targetSize)
|
ChangeMapSizeAction::ChangeMapSizeAction(const TileCoordsXY& targetSize)
|
||||||
: _targetSize(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);
|
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);
|
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_DECREASE_MAP_SIZE_ANY_FURTHER, STR_NONE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class ChangeMapSizeAction final : public GameActionBase<GameCommand::ChangeMapSi
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ChangeMapSizeAction() = default;
|
ChangeMapSizeAction() = default;
|
||||||
ChangeMapSizeAction(const TileCoordsXY targetSize);
|
ChangeMapSizeAction(const TileCoordsXY& targetSize);
|
||||||
|
|
||||||
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
void AcceptParameters(GameActionParameterVisitor& visitor) override;
|
||||||
uint16_t GetActionFlags() const override;
|
uint16_t GetActionFlags() const override;
|
||||||
|
|||||||
@@ -458,16 +458,16 @@ void FootpathPlaceAction::AutomaticallySetPeepSpawn() const
|
|||||||
{
|
{
|
||||||
auto mapSizeUnits = GetMapSizeUnits();
|
auto mapSizeUnits = GetMapSizeUnits();
|
||||||
uint8_t direction = 0;
|
uint8_t direction = 0;
|
||||||
if (_loc.x != 32)
|
if (_loc.x != COORDS_XY_STEP)
|
||||||
{
|
{
|
||||||
direction++;
|
direction++;
|
||||||
if (_loc.y != mapSizeUnits.y - 32)
|
if (_loc.y != mapSizeUnits.y - COORDS_XY_STEP)
|
||||||
{
|
{
|
||||||
direction++;
|
direction++;
|
||||||
if (_loc.x != mapSizeUnits.x - 32)
|
if (_loc.x != mapSizeUnits.x - COORDS_XY_STEP)
|
||||||
{
|
{
|
||||||
direction++;
|
direction++;
|
||||||
if (_loc.y != 32)
|
if (_loc.y != COORDS_XY_STEP)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ GameActions::Result PlaceParkEntranceAction::Query() const
|
|||||||
res.Expenditure = ExpenditureType::LandPurchase;
|
res.Expenditure = ExpenditureType::LandPurchase;
|
||||||
res.Position = { _loc.x, _loc.y, _loc.z };
|
res.Position = { _loc.x, _loc.y, _loc.z };
|
||||||
|
|
||||||
auto mapSizeUnits = GetMapSizeUnits() - CoordsXY{ 32, 32 };
|
auto mapSizeUnits = GetMapSizeUnits() - CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP };
|
||||||
if (!LocationValid(_loc) || _loc.x <= 32 || _loc.y <= 32 || _loc.x >= mapSizeUnits.x || _loc.y >= mapSizeUnits.y)
|
if (!LocationValid(_loc) || _loc.x <= COORDS_XY_STEP || _loc.y <= COORDS_XY_STEP || _loc.x >= mapSizeUnits.x
|
||||||
|
|| _loc.y >= mapSizeUnits.y)
|
||||||
{
|
{
|
||||||
return GameActions::Result(
|
return GameActions::Result(
|
||||||
GameActions::Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_TOO_CLOSE_TO_EDGE_OF_MAP);
|
GameActions::Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_TOO_CLOSE_TO_EDGE_OF_MAP);
|
||||||
|
|||||||
@@ -683,8 +683,8 @@ void SetCheatAction::SetStaffSpeed(uint8_t value) const
|
|||||||
|
|
||||||
void SetCheatAction::OwnAllLand() const
|
void SetCheatAction::OwnAllLand() const
|
||||||
{
|
{
|
||||||
const auto min = CoordsXY{ 32, 32 };
|
const auto min = CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP };
|
||||||
const auto max = GetMapSizeUnits() - CoordsXY{ 32, 32 };
|
const auto max = GetMapSizeUnits() - CoordsXY{ COORDS_XY_STEP, COORDS_XY_STEP };
|
||||||
|
|
||||||
for (CoordsXY coords = min; coords.y <= max.y; coords.y += COORDS_XY_STEP)
|
for (CoordsXY coords = min; coords.y <= max.y; coords.y += COORDS_XY_STEP)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,8 +87,8 @@ static std::vector<RecordedPaintSession> extract_paint_session(std::string_view
|
|||||||
gIntroState = IntroState::None;
|
gIntroState = IntroState::None;
|
||||||
gScreenFlags = SCREEN_FLAGS_PLAYING;
|
gScreenFlags = SCREEN_FLAGS_PLAYING;
|
||||||
|
|
||||||
int32_t resolutionWidth = (gMapSize.x * 32 * 2);
|
int32_t resolutionWidth = (gMapSize.x * COORDS_XY_STEP * 2);
|
||||||
int32_t resolutionHeight = (gMapSize.y * 32 * 1);
|
int32_t resolutionHeight = (gMapSize.y * COORDS_XY_STEP * 1);
|
||||||
|
|
||||||
resolutionWidth += 8;
|
resolutionWidth += 8;
|
||||||
resolutionHeight += 128;
|
resolutionHeight += 128;
|
||||||
@@ -102,15 +102,11 @@ static std::vector<RecordedPaintSession> extract_paint_session(std::string_view
|
|||||||
viewport.var_11 = 0;
|
viewport.var_11 = 0;
|
||||||
viewport.flags = 0;
|
viewport.flags = 0;
|
||||||
|
|
||||||
int32_t customX = (gMapSize.x / 2) * 32 + 16;
|
auto customXY = TileCoordsXY(gMapSize.x / 2, gMapSize.y / 2).ToCoordsXY().ToTileCentre();
|
||||||
int32_t customY = (gMapSize.y / 2) * 32 + 16;
|
auto customXYZ = CoordsXYZ(customXY, tile_element_height(customXY));
|
||||||
|
auto screenXY = translate_3d_to_2d_with_z(0, customXYZ);
|
||||||
|
|
||||||
int32_t x = 0, y = 0;
|
viewport.viewPos = { screenXY.x - (viewport.view_width / 2), screenXY.y - (viewport.view_height / 2) };
|
||||||
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.zoom = ZoomLevel{ 0 };
|
viewport.zoom = ZoomLevel{ 0 };
|
||||||
gCurrentRotation = 0;
|
gCurrentRotation = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -217,8 +217,8 @@ enum class EdgeType
|
|||||||
static CoordsXY GetEdgeTile(TileCoordsXY mapSize, int32_t rotation, EdgeType edgeType, bool visible)
|
static CoordsXY GetEdgeTile(TileCoordsXY mapSize, int32_t rotation, EdgeType edgeType, bool visible)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
int32_t lower = (visible ? 1 : 0) * 32;
|
int32_t lower = (visible ? 1 : 0) * COORDS_XY_STEP;
|
||||||
int32_t upper = (visible ? mapSize.x - 2 : mapSize.x - 1) * 32;
|
int32_t upper = (visible ? mapSize.x - 2 : mapSize.x - 1) * COORDS_XY_STEP;
|
||||||
switch (edgeType)
|
switch (edgeType)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
@@ -688,8 +688,8 @@ int32_t cmdline_for_screenshot(const char** argv, int32_t argc, ScreenshotOption
|
|||||||
const auto& mapSize = gMapSize;
|
const auto& mapSize = gMapSize;
|
||||||
if (resolutionWidth == 0 || resolutionHeight == 0)
|
if (resolutionWidth == 0 || resolutionHeight == 0)
|
||||||
{
|
{
|
||||||
resolutionWidth = (mapSize.x * 32 * 2) >> customZoom;
|
resolutionWidth = (mapSize.x * COORDS_XY_STEP * 2) >> customZoom;
|
||||||
resolutionHeight = (mapSize.y * 32 * 1) >> customZoom;
|
resolutionHeight = (mapSize.y * COORDS_XY_STEP * 1) >> customZoom;
|
||||||
|
|
||||||
resolutionWidth += 8;
|
resolutionWidth += 8;
|
||||||
resolutionHeight += 128;
|
resolutionHeight += 128;
|
||||||
|
|||||||
@@ -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 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 LAND_HEIGHT_STEP = 2 * COORDS_Z_STEP;
|
||||||
constexpr const int32_t MINIMUM_LAND_HEIGHT_BIG = MINIMUM_LAND_HEIGHT * 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)
|
#define MAP_MINIMUM_X_Y (-MAXIMUM_MAP_SIZE_TECHNICAL)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user