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: Build objects by area #9709

Merged
merged 2 commits into from Oct 16, 2022
Merged

Conversation

2TallTyler
Copy link
Member

Motivation / Problem

Building decorative objects one tile at a time is tedious.

JGRPP includes a feature to build objects by drag-and-drop, including diagonally by holding Ctrl.

Description

Upstreams JGR's commit, with modifications for vanilla.

Also includes a commit to limit the rate of object construction, to prevent griefing.

Limitations

I haven't touched saveload upgrades in a while and JGRPP handles it differently, so please check this carefully!

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@LC-Zorg
Copy link

LC-Zorg commented Nov 19, 2021

This PR is like a warm bath after all day in the cold... ;)

However, I would have a few comments that might be worth considering. I'm writing this having in mind possible improvements to this function, including PR or in the future separately.

  1. There is a real risk of using objects to block other players in online games. Therefore, such a possibility should be an option or there should be a setting to limit the construction area - JGR has the following settings:
    build_object_per_64k_frames = 2097152
    build_object_frame_burst = 2048
    If this PR is also adding them, that should be enough.

  2. Is it possible to limit the stretching of the construction mesh so that the area is not larger than in the build_object_frame_burst setting? It is a bit strange when you can stretch a construction field without limit, and finally there will be, for example, 1 object on it.
    disappointment
    example with build_object_frame_burst = 1

  3. It will be much easier to reserve an area with objects than by purchasing it. Could this change also apply to the purchase of land? It seems to me that there is no need to separate it - both are de facto objects.

  4. This change will allow area-based construction of all 1x1 size objects, but many of these should not necessarily be able to do so. Perhaps the creators should be able to add markings that will prevent such construction of selected objects.

@2TallTyler
Copy link
Member Author

  1. This PR includes such settings, as well as the global on/off switch (in Settings, chosen by the server owner for all players) for building multiple objects at once. 😄
  2. If a server wants to limit building more than one object, they should turn the feature off completely rather than limiting it with the burst limit.
  3. JGRPP also includes this feature, but it is a separate command code-wise and I think would be a separate PR.
  4. I don't see a problem with the player doing what they want, besides it looking silly. Forcibly limiting certain objects to a size chosen by the NewGRF author would require an addition to the NewGRF spec, and would be Too Much Work For Too Little Benefit, in my opinion.

src/saveload/saveload.h Outdated Show resolved Hide resolved
src/settings_type.h Outdated Show resolved Hide resolved
src/object_cmd.cpp Outdated Show resolved Hide resolved
src/object_cmd.cpp Outdated Show resolved Hide resolved
src/object_cmd.cpp Outdated Show resolved Hide resolved
@2TallTyler 2TallTyler force-pushed the area-objects branch 2 times, most recently from 3f0cdd9 to e8c2c12 Compare December 5, 2021 18:48
@LC-Zorg
Copy link

LC-Zorg commented Dec 5, 2021

Is there an example for when someone would want to disable this? (i.e. why is this a setting?)

Point 1 in my comments above. Roads and tracks build slower - for some, it can be a new, more powerful tool for sowing chaos on servers. ;)

@2TallTyler
Copy link
Member Author

I tried to rebase this to use the new Command structure, but I'm getting lots of incomprehensible (to me) build errors in network_command.cpp. What am I doing wrong?

@stormcone
Copy link
Contributor

I think it is because there is a missing a DEF_CMD_TRAIT in object_cmd.h.

Similar to this:

DEF_CMD_TRAIT(CMD_BUILD_OBJECT, CmdBuildObject, CMD_DEITY | CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION)

I'm unsure about the parameters, but something like this:
DEF_CMD_TRAIT(CMD_BUILD_OBJECT_AREA, CmdBuildObjectArea, CMD_DEITY | CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION)

@2TallTyler
Copy link
Member Author

Thanks for the tip! It builds now, but no longer works. Only one object gets built. 😕

src/object_gui.cpp Outdated Show resolved Hide resolved
@2TallTyler
Copy link
Member Author

It works! One final issue: when I try to build an extremely large area of objects, which I could afford if it weren't too large an area to be allowed, I get an assertion error:
res_test.GetCost() == res_exec.GetCost() && res_test.Failed() == res_exec.Failed()

src/object_cmd.cpp Outdated Show resolved Hide resolved
src/object_cmd.cpp Outdated Show resolved Hide resolved
src/object_cmd.cpp Outdated Show resolved Hide resolved
src/object_cmd.cpp Outdated Show resolved Hide resolved
src/object_gui.cpp Outdated Show resolved Hide resolved
src/object_gui.cpp Outdated Show resolved Hide resolved
src/object_gui.cpp Outdated Show resolved Hide resolved
src/company_cmd.cpp Show resolved Hide resolved
src/object_cmd.cpp Outdated Show resolved Hide resolved
src/object_cmd.cpp Outdated Show resolved Hide resolved
src/object_gui.cpp Outdated Show resolved Hide resolved
src/object_gui.cpp Outdated Show resolved Hide resolved
src/settings_type.h Outdated Show resolved Hide resolved
src/object_cmd.cpp Outdated Show resolved Hide resolved
LordAro
LordAro previously approved these changes Aug 29, 2022
@2TallTyler
Copy link
Member Author

I forgot to update tooltips to indicate that you can press Ctrl to select diagonally. Ready for a re-review. 🙂

@michicc michicc added the preview This PR is receiving preview builds label Oct 16, 2022
@DorpsGek DorpsGek temporarily deployed to preview-pr-9709 October 16, 2022 12:38 Inactive
src/object_cmd.cpp Outdated Show resolved Hide resolved
src/object_cmd.h Outdated Show resolved Hide resolved
src/object_cmd.cpp Outdated Show resolved Hide resolved
src/object_gui.cpp Outdated Show resolved Hide resolved
@DorpsGek DorpsGek temporarily deployed to preview-pr-9709 October 16, 2022 13:15 Inactive
@DorpsGek DorpsGek temporarily deployed to preview-pr-9709 October 16, 2022 15:43 Inactive
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

7 participants