Patch: Limit leveling tool at sea level
Moderator: OpenTTD Developers
Patch: Limit leveling tool at sea level
This is a quick patch to limit how much land leveling can be done in one shot at sea level. When enabled by server admins, this will help avoid "waterworld" maps where players get rich, bored, and unable to resist the temptation of lowering everything to sea level. Screenshots and patch attached.
Please check this thread in OpenTTD Suggestions for discussion.
Edit: updated patch and screenshot, below.
Please check this thread in OpenTTD Suggestions for discussion.
Edit: updated patch and screenshot, below.
Last edited by benc on 02 Jun 2007 06:48, edited 1 time in total.
That's already how it works.dihedral wrote:now this has to become a server setting, i.e. set in the server .cfg file, and greyed out for the clients!

I don't think it's worth the complexity of having an extra setting for that. And as others pointed out in the Suggestions thread, this would block a lot of legitimate uses of the leveling tool. E.g., carving a long canyon through hills doesn't screw up the map.dihedral wrote:add an option to specify if this should only take affect when leveling to sea-level, or for leveling land in general
Sea level is always tile height 0. (If you change "sea level" when generating a new world, you're just setting a TerraGenesis parameter... not changing the internal tile height.)dihedral wrote:also make sure that it works when sea-level is not 0 but lets assume 2
of course it's not... but it's a start, not a good one, but one to get started with
and once that works, add a check on the server side, as you clearly will want both sides to wrok together!!!
being able to client side say i want to blow up 20x20 tiles and server only allows 10, it is nicer to have a gui limit in it.
so rather than critisizing... how about just taking it on from here and thinking of this as a good way to start solving the issue ?
@benc: if i am not mistaken it was only you who wanted to only check if leveling to sea level... !!!
and once that works, add a check on the server side, as you clearly will want both sides to wrok together!!!
being able to client side say i want to blow up 20x20 tiles and server only allows 10, it is nicer to have a gui limit in it.
so rather than critisizing... how about just taking it on from here and thinking of this as a good way to start solving the issue ?
@benc: if i am not mistaken it was only you who wanted to only check if leveling to sea level... !!!
Thanks for the patch review, peter1138... much appreciated. I've updated the patch to also enforce the limit in at the cmd level, where it should be.
I had to work around a clever hack in CmdLevelLand() that blocks the dynamite sound when you try to level an already-flat piece of land. Took me a few to figure it out, so I added some comments explaining what's going on. A cleaner solution might be to be to replace bool success with int32 res in the CommandCallback signature. But that's beyond the scope of this patch.
This patch also fixes a minor bug that hack introduced. If you hold shift to get a cost estimate on leveling an already-flat piece of land, an empty red error message window pops up. The bug exists in r10018 and 0.5.2.
Finally, I added a second patch option for server admins who want to limit all land leveling, not just at sea-level. Setting the limit to 1 effectively disables the leveling tool entirely. Enjoy!
I had to work around a clever hack in CmdLevelLand() that blocks the dynamite sound when you try to level an already-flat piece of land. Took me a few to figure it out, so I added some comments explaining what's going on. A cleaner solution might be to be to replace bool success with int32 res in the CommandCallback signature. But that's beyond the scope of this patch.

This patch also fixes a minor bug that hack introduced. If you hold shift to get a cost estimate on leveling an already-flat piece of land, an empty red error message window pops up. The bug exists in r10018 and 0.5.2.
Finally, I added a second patch option for server admins who want to limit all land leveling, not just at sea-level. Setting the limit to 1 effectively disables the leveling tool entirely. Enjoy!
- Attachments
-
- max_level_limit.png (6.02 KiB) Viewed 5943 times
-
- limit_level_v2.diff
- (6.41 KiB) Downloaded 503 times
Who is online
Users browsing this forum: No registered users and 8 guests