Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add the ability to clone an area with structures #12657

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

StanislavShamrai
Copy link

@StanislavShamrai StanislavShamrai commented May 11, 2024

Motivation / Problem

@StanislavShamrai wants to automate a process by creating a new object using existing logic.

Description

You can build larger paths by simply copying and pasting some of the existing intersections and paths.
You can rotate an area by inserting it at a different angle.

Limitations

This was created for railroad tracks, tunnels, and bridges, but the same behavior may be added for other types of tracks and structures in the future.

Checklist for review

example:
clone-area.webm

@Kuhnovic Kuhnovic added the preview This PR is receiving preview builds label May 11, 2024
Copy link
Member

@PeterN PeterN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems well written, though maybe a bit repetitive (I guess that's the point :D)

src/terraform_gui.cpp Outdated Show resolved Hide resolved
src/clone_area_cmd.cpp Outdated Show resolved Hide resolved
src/clone_area_cmd.cpp Outdated Show resolved Hide resolved
…gestions from code review

Co-authored-by: Peter Nelson <peter@fuzzle.org>
if (HasSignalOnTrack(iter_tile, track)) {
SignalType sigtype = GetSignalType(iter_tile, track);
SignalVariant sigvar = GetSignalVariant(iter_tile, track);
CommandCost ret = Command<CMD_BUILD_SINGLE_SIGNAL>::Do(flags, dest_tile, track_dest, sigtype, sigvar, false, false, false, SIGTYPE_BLOCK, SIGTYPE_BLOCK, 0, 0);

Check notice

Code scanning / CodeQL

Declaration hides variable Note

Variable ret hides another variable of the same name (on
line 406
).
cost.AddCost(ret);
if (flags & DC_EXEC) {
if (dest_station_id == NEW_STATION) {
StationID dest_station_id = GetStationIndex(dest_tile);

Check notice

Code scanning / CodeQL

Declaration hides variable Note

Variable dest_station_id hides another variable of the same name (on
line 498
).
* @param diagonal build diagonally or not.
* @return the cost of this operation or an error
*/
std::tuple<CommandCost, Money, TileIndex> CmdCloneAreaPasteProperty(DoCommandFlag flags, TileIndex tile, TileIndex area_start, [[maybe_unused]] bool diagonal)

Check warning

Code scanning / CodeQL

Poorly documented large function Warning

Poorly documented function: fewer than 2% comments for a function of 186 lines.
@PeterN
Copy link
Member

PeterN commented May 18, 2024

The list of commits looks a bit messy, did you mean to squash it again?

Additionally there are a lot of seemingly unrelated changes into table/sprites.h which might be better in a separate PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview This PR is receiving preview builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants