Patch: Limit leveling tool at sea level

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
User avatar
benc
Engineer
Engineer
Posts: 62
Joined: 30 Apr 2007 01:57

Patch: Limit leveling tool at sea level

Post by benc »

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.
Last edited by benc on 02 Jun 2007 06:48, edited 1 time in total.
dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Post by dihedral »

now this has to become a server setting, i.e. set in the server .cfg file, and greyed out for the clients!

add an option to specify if this should only take affect when leveling to sea-level, or for leveling land in general

also make sure that it works when sea-level is not 0 but lets assume 2 :-)
User avatar
benc
Engineer
Engineer
Posts: 62
Joined: 30 Apr 2007 01:57

Post by benc »

dihedral wrote:now this has to become a server setting, i.e. set in the server .cfg file, and greyed out for the clients!
That's already how it works. :-) You can only change the setting via the GUI if you're the server or running single-player.
dihedral wrote:add an option to specify if this should only take affect when leveling to sea-level, or for leveling land in general
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:also make sure that it works when sea-level is not 0 but lets assume 2 :-)
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.)
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1659
Joined: 30 Mar 2005 09:43

Post by peter1138 »

Enforcing the limit in GUI code is not the right place to do it...
He's like, some kind of OpenTTD developer.
dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Post by dihedral »

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... !!!
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1659
Joined: 30 Mar 2005 09:43

Post by peter1138 »

Purely statement of fact.
He's like, some kind of OpenTTD developer.
dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Post by dihedral »

well... if you put it that way... :-P
User avatar
benc
Engineer
Engineer
Posts: 62
Joined: 30 Apr 2007 01:57

Post by benc »

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!
Attachments
max_level_limit.png
max_level_limit.png (6.02 KiB) Viewed 5221 times
limit_level_v2.diff
(6.41 KiB) Downloaded 466 times
dihedral
Tycoon
Tycoon
Posts: 1053
Joined: 14 Feb 2007 17:48

Post by dihedral »

you're a genius... thanks a lot for making a patch available so quickly :-)

now it would be interesting to see what happens when the server is patched and the clients are not *evil grin*
elmex
Engineer
Engineer
Posts: 16
Joined: 24 May 2007 23:01

Post by elmex »

thanks too for implementing this so fast! :-)

@dihedral: if the sever also enforces the limits and it's not only a client
GUI thing you will probably get desyncs :-) (i've tried once with my own small proof-of-concept patch which just disabled leveling).
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 5 guests