Page 1 of 4

Yet another autoslope patch (in trunk since r11107)

Posted: 22 Aug 2007 15:23
by frosch
This patch features:
* A new item "Allow terraforming under buildings, tracks, etc. (autoslope)" (english only) in "patch options"->"construction" (second from top, under 'build on slopes'). (enabled by default)
* If enabled: Terraforming under things without removing them. (TTDP calls it autoslope)

The patch increases the savegame version from 74 to 75. That means trunk cannot load savegames created with this patch.
The patch cannot load savegames of versions before r11051 of this patch. So make sure you do not want to continue your old games.

Autoslope is enabled under
* tracks/roads/stations if 'build on slopes' is enabled.
* houses/industries if they allow that. (This is controlled by newgrf properties resp. their default values)
* statues and company headquarters.

Autoslope in disabled
* under transmitters and lighthouses.
* for non-players like towns and industries. (They terraform on expansion/creation)

Autosloping causes terraforming cost to be doubled.

NewGRF related things:
Compliant to TTDP's autoslope behavior, except for houses, where Action 0 house property 09 'flat land required' is checked.

Enjoy it!

Re: Yet another autoslope patch (90 percent complete)

Posted: 22 Aug 2007 22:34
by kaan
A quick peek at this was a very pleasant experience, looks like you did a fine job here :)

Re: Yet another autoslope patch (90 percent complete)

Posted: 23 Aug 2007 08:36
by boekabart
Without even looking at the patch, I'm very impressed with your approach - you seem to have done your preparation in trying to understand the full implications of this patch - no half work! I'll try to find some time to comment on the patch itself later on.

Re: Yet another autoslope patch (90 percent complete)

Posted: 23 Aug 2007 11:01
by Roujin
first of all, like boekabart said, your post looks really promising for itself. I wish you good luck with this project, i'm definately looking forward to this! :)

I'll give you my thoughts about the points that are still open.
frosch wrote:[...]
However there are some things open:
* Should terraforming under things cause "Vehicle in the way"? (Currently it does not)
No. IMO this should only be caused when the track the vehicle is running on would be changed.
It's the same annoying thing like signaling/building/clearing a diagonal piece of track with another (occupied) piece of track on the same tile. This was only recently fixed by a patch, and it would IMO be a fun-blocker if this kind of limitation was introduced here again.
[edit]okay, i just noticed that was your patch :lol: :oops: [/edit]
* Should terraforming under things be disabled during world generation, town expansion and industry construction? (Currently it is enabled)
good question. What would happen if it's enabled during these actions? probably needs some testing - if strange things happen, it can be deactivated still.
* What is the effect of enabled 'autoslope' but disabled 'build on slopes'. (Currently it then allows autosloping only under houses)
current behavior sounds pretty reasonable. no sloping of tracks (, stations...) afterwards. don't allow anything to be created which you can't clear and then rebuild just like this.
* Should terraforming under light houses/transmitters be allowed? (Currently it is enabled with 'build on slopes')
maybe some will disagree with me here, but i'd say no. LH/transmitters aren't supposed to stand on a slope. but i'm open for discussion here.
* In some cases railroad should get dirty ground if the foundation changes.
[...]
i don't exactly know what you mean here. I'll have a look at the game with your patch right now, maybe that will clear it up for me.
[edit]ok, i guess you mean what i attached to the post (in reverse as well of course). yes, this tile should get dirty ground, since the actual surface changes. Other than in normal case.
sad that we can't have only half of the tile with dirty ground. That would be awesome. *dreaming* ^^

(maybe your next project?) :mrgreen:

[/edit]



I'll keep myself from commenting on the more internal stuff, since i don't really know about that ;)

cheers :)

edit: played around with it for a bit, and edited my post accordingly ;)

Re: Yet another autoslope patch (90 percent complete)

Posted: 23 Aug 2007 13:20
by frosch
Updated first post.

First I forgot to mention, that I had to increase the savegame version from 73 to 74. That means trunk cannot load savegames created with this patch.

New questions:
* Currently autosloping has extra-costs of '_price.terraform' (This price is used for terraforming one step on clear land, and for building foundations'. Perhaps add an extra cost like half of the clear-land costs, if the tile is not owned by the player. This will make autosloping under industries and important townbuildings more expensive.
* Should we ask the local authority before autosloping under houses?

Changes:
* Terraforming under railway will make the ground dirty, if the surface slope changes.
* Disable autoslope during world generation. This way a specific 'random seed' will cause the same world independent of 'autoslope'-setting.

Fixes:
* Forgot 'on'/'off' text in patch settings.
* Terraforming showed a red pulsating error square, if only money was not sufficient.
* Removed some bogus whitespace. (Spotted by Rubidium, thanks)

@Roujin:
Thanks for your opinion. I will wait for some more, and then make a decision.
About the dirty halftile: If you find appropiate space in the map array, even mixed track types on one tile are possible (like parallel horizontal/vertical rail and monorail). The code to draw clipped sprites (i.e. the half of a ground sprite) is already in the still unreleased HalftileFoundations patch (see Topic 'Less restrictive rail construction').

Re: Yet another autoslope patch (90 percent complete)

Posted: 23 Aug 2007 13:56
by belugas
About your questions on newgrf, i wonder why you asked.
From what I can remember, those calls are made during creation of the entity (industry, house, station etc) and therefore, you do not need to perform it after it has been built.
Or maybe there is something else that i have not seem which could very well be.

The fact that you made such extended search in the codebase is very good and pretty uncommun ;)
And it caugh the attention of a lot of people :)

Re: Yet another autoslope patch (90 percent complete)

Posted: 23 Aug 2007 14:24
by frosch
Well, the thing is, that these callback can check the tile slope.
About stations I only have one screenshot by Michael Blunck on the german forum:
(Currently) last post on http://www.tt-ms.de/forum/showthread.ph ... 409&page=7.
What happens if I autoslope a corner under such a custom foundation and get a slope the newgrf does not provide a foundation for.

The same holds for industries.
To check an action 0 property is no problem. But if callback 2F is enabled, I have to call it, to know if a steep slope is allowed. Odd is, that probably all grfs will disable autosloping under their industries.
I once considered to call the callbacks for all 23 slopes on creation, so the callbacks are synchronized over the network. But variable 60 allows to check slopes on completely unrelated tiles (though nobody will use this feature).
So perhaps a solution could be: Call callback 3C 'autoslope allowed' on creation of the industry. If it is allowed use action 0 property 0D to test if a slope is allowed. But if callback 2F is enabled there must be a static decision. Either do not allow autosloping at all, or allow every slope, even steep. (I think the first)

The behaviour of TTDP (though I am not good enough in assembler to fully understand it) seems to call only the autoslope callback, and then allow all non-steep slopes. It does not seem to check the action 0 properties of house and industry slope restrictions. But perhaps I looked at the wrong place in the code.

Re: Yet another autoslope patch (90 percent complete)

Posted: 23 Aug 2007 15:06
by Maedhros
Here's my input. :)
frosch wrote:* Should terraforming under things cause "Vehicle in the way"? (Currently it does not)
I would say yes, but I don't really have a strong opinion about it.
frosch wrote:* Should terraforming under things be disabled for town expansion and industry construction? (Currently it is enabled)
Yes.
frosch wrote:* What is the effect of enabled 'autoslope' but disabled 'build on slopes'. (Currently it then allows autosloping only under houses)
Sounds sensible to me - houses are the only things I can think of that can be built on slopes and have foundations.
frosch wrote:* Should terraforming under light houses/transmitters be allowed? (Currently it is enabled with 'build on slopes')
No, but again I don't have a strong opinion on this one.
frosch wrote:* Should autoslope check Action 0 House Property 09 'flat land required'? (Currently it does.)
Yes.
frosch wrote:* Should it call House Callback 17 'can house be build on tile' with the new slope in variable 62 'land info of nearby tiles'? (Currently it does not.)
No, this callback should only be called when a house is built, as it can check many other things than the tile slope. In TTRS2 (I'm not entirely sure about v3) you can only have 3 hospitals on the map, so if you call it when autosloping and there are 3 hospitals on the map it will always fail.
frosch wrote:* Should it call Station Callback 149 'custom slope check' with the new slope in variable 67 'land info of nearby tiles'. (Currently not implemented at all.)
Probably, but since it isn't implemented yet you probably don't have to worry about it for the moment.
frosch wrote:* Should it check Action 0 Industrytile Property 0D 'land shape flags'? (well newindustries..., but I guess it should check)
I'd say yes.
frosch wrote:* It surely should call Industry Callback 3C 'allow or deny autosloping', but what is the default value if the callback is not enabled? (I guess allow it.) And should Variable 60 'land info of nearby tiles' refer to the new slope.
By the looks of it, if the callback is not enabled, or it fails, autosloping is allowed. And yes, var 60 should refer to whatever the slope is actually there.
frosch wrote:* Should it call Industry Callback 2F 'check if slope suitable' or Callback 28 'Industry location permissibility' with new slope in variable 60 'land info of nearby tiles' (I guess don't call.)
I guess not, since there's a callback explicitly for autoslope already.
frosch wrote:* And if it calls a callback, is it the grf's fault, if it causes desyncs? (Query-cost-only commands are not send over the network.)
Yes.

Good job by the way, the patch is looking great. :)

Re: Yet another autoslope patch (90 percent complete)

Posted: 23 Aug 2007 17:42
by DJ Nekkid
with all theese commets i smell a submission to trunk soon :)

Re: Yet another autoslope patch (90 percent complete)

Posted: 23 Aug 2007 19:47
by Bot_40
Well I'd just like to echo what everybody else has said really, I've been lurking here for a good couple of years and I'm quite amazed at how much thought you are putting into this patch. Excellent work! :)

...Especially compared to how a certain someone reacted to comments on his related patch... :roll:
frosch wrote:* Should terraforming under things cause "Vehicle in the way"? (Currently it does not)
Well I would say for realism - yes, for gameplay - no. This is the only thing I have a strong opinion on and I personally would always take gameplay over realism in something like this.

Also, disallowing autoslopes when a vehicle is on the tile would probably cause annoyance with stations. Forcing someone to wait for a large train to finish loading and leave a station so you can lower some land is not exactly fun gameplay.

Re: Yet another autoslope patch (90 percent complete)

Posted: 23 Aug 2007 23:05
by NukeBuster
Nice job, on this patch. It looks really promising. I've read the questions, and I like to give my opinion.
frosch wrote: However there are some things open:
* Should terraforming under things cause "Vehicle in the way"? (Currently it does not)
Only if the train is on the same side of the track, where you want to change the slope.
frosch wrote: * Should terraforming under things be disabled for town expansion and industry construction? (Currently it is enabled)
Yes. (It should be the same for tunnels. At least directly below the industry.)
frosch wrote: * What is the effect of enabled 'autoslope' but disabled 'build on slopes'. (Currently it then allows autosloping only under houses)
Only under houses seems reasonable.
frosch wrote: * Should terraforming under light houses/transmitters be allowed? (Currently it is enabled with 'build on slopes')
No, as they are usually placed to keep mountains from extensive terraforming.
frosch wrote: * Currently autosloping has extra-costs of '_price.terraform' (This price is used for terraforming one step on clear land, and for building foundations). Perhaps add an extra cost like half of the clear-land costs, if the tile is not owned by the player. This will make autosloping under industries and important townbuildings more expensive.
I'd say, add the extra costs. But It shouldn't be more than you would now when destroying buildings and terraforming.
frosch wrote: * Should we ask the local authority before autosloping under houses?
Yes, but it should be more permissive towards autosloping than destroying a city block. As you would do without autoslope.
frosch wrote: NewGRF related things:
* Should autoslope check Action 0 House Property 09 'flat land required'? (Currently it does.)
* Should it call House Callback 17 'can house be build on tile' with the new slope in variable 62 'land info of nearby tiles'? (Currently it does not.)

* Should it call Station Callback 149 'custom slope check' with the new slope in variable 67 'land info of nearby tiles'. (Currently not implemented at all.)

* Should it check Action 0 Industrytile Property 0D 'land shape flags'? (well newindustries..., but I guess it should check)
* It surely should call Industry Callback 3C 'allow or deny autosloping', but what is the default value if the callback is not enabled? (I guess allow it.) And should Variable 60 'land info of nearby tiles' refer to the new slope
* Should it call Industry Callback 2F 'check if slope suitable' or Callback 28 'Industry location permissibility' with new slope in variable 60 'land info of nearby tiles' (I guess don't call.)

* And if it calls a callback, is it the grf's fault, if it causes desyncs? (Query-cost-only commands are not send over the network.)

But for now, enjoy it!
As I don't know anything about grfs. My comments on these questions would probably be useless.

I'm really looking forward to seeing more of your work.

Re: Yet another autoslope patch (90 percent complete)

Posted: 24 Aug 2007 00:07
by DaleStan
frosch wrote:* Should terraforming under light houses/transmitters be allowed? (Currently it is enabled with 'build on slopes')
Yes.
NukeBuster: Autoslope doesn't allow changing the foundation-ed height of something. Only the foundation itself.
frosch wrote:* Should we ask the local authority before autosloping under houses?
No.
That's half the point. So you can build without disturbing the LA.
frosch wrote:NewGRF related things:
Read the docs.
If it's documented as "during construction", then it applies *during* construction. Autoslope happens, by definition, *after* construction.
If it's documented as effecting autoslope, then it effects autoslope.

If it's not documented, test it in TTDPatch (cht:grfdebug is your friend) and then document the results.
frosch wrote:* And if it calls a callback, is it the grf's fault, if it causes desyncs? (Query-cost-only commands are not send over the network.)
No. GRFs cannot cause desyncs. If your query-cost commands are changing things, then they are broken, not any GRF that they may query.

Re: Yet another autoslope patch (90 percent complete)

Posted: 24 Aug 2007 00:10
by athanasios
frosch wrote:* Should terraforming under things cause "Vehicle in the way"?
No. It would make the patch useless when terraforming in a city with many road vehicles.
frosch wrote:* Should terraforming under light houses/transmitters be allowed? (Currently it is enabled with 'build on slopes')
I suppose all buildings have basements and foundations (supporting pillars - not the game's slope foundations). OK, this is not implemented in the game yet but it should. We should at least reserve 1 height and more for special buildings and not be able to tunnel there. For special industries like Coal Mine as suggested before it should not be allowed at all to tunnel under. So: For lighthouse reserve 1 height under but allow slope foundations, transmitter doesn't require any deep supports so terraforming under it should be allowed.
frosch wrote:* Should we ask the local authority before autosloping under houses?
If you mean that allowance will depend on your ratings: yes. But no extra lowering of ratings.
frosch wrote:But for now, enjoy it!
Sure! :mrgreen:

Re: Yet another autoslope patch (90 percent complete)

Posted: 24 Aug 2007 07:12
by Acerbus
frosch wrote:* Should terraforming under things cause "Vehicle in the way"? (Currently it does not)
Nope, although that would make it a bit more realistic, it would not be enough to counter the gameplay annoyances.
frosch wrote:* Should we ask the local authority before autosloping under houses?
I think it should be handled the same way as usual terraforming, it should decrease your ratings, but should be allowed no matter what your ratings are.

Yet another great patch I wanna see in the trunk asap!

Re: Yet another autoslope patch (90 percent complete)

Posted: 24 Aug 2007 10:44
by Roujin
@new questions since my post:
frosch wrote:* Currently autosloping has extra-costs of '_price.terraform' (This price is used for terraforming one step on clear land, and for building foundations'. Perhaps add an extra cost like half of the clear-land costs, if the tile is not owned by the player. This will make autosloping under industries and important townbuildings more expensive.
Neutral, tending to no. Well i could live with extra costs, but i personally think of autosloping in a certain way: actually if you lower some edge and a tile would get autosloped because of this, the particular tile is not touched (like, worked on with building vehicles and equipment). Only the other up to three tiles need working on. (I know it's not like this internally, but i mean logically. Of course you'll notice that it's not really like this once the building on this tile is demolished.) Thus, the price should rather be 3/4 of normal than more than normal. But i think normal price is ok, counting in that you would have to stabilize the vertical foundation or something... that costs the price again that would have been preserved by not having to dig out that particular tile.
* Should we ask the local authority before autosloping under houses?
No, meaning do not forbid if rating is bad. Decrease of rating similar to normal land raising/lowering.

My answers of these two plus the question about "vehicle in the way" all have the same reason, like stated above. I'd treat autoslope gameplay-wise like you don't have to work on the occupied tile. (This also corresponds with the look.) Thus, it doesn't matter if there's a vehicle on it, it doesn't matter if there's a building on it from a city who doesn't like you and it won't cost extra if there's an expensive building on it, since you don't actually send your workers on that tile.


Hope that was kind of understandable :oops:
and finally one more question: what is the clear tile cost of industries? is there any at all? maybe it would get incredibly expensive then... (thinking about the build costs of industries)

Re: Yet another autoslope patch (90 percent complete)

Posted: 24 Aug 2007 15:16
by frosch
Thanks for the friendly feedback :)

Ok, now sum up.

Vehicle in the way:
I agree with the majority. The surface is not changed, the grass remains, and vehicles are not in the way.

Towns' and industries' usage of autoslope:
I feel like most did not understood me in this point. When towns expand or a new industry appears they terraform a bit, to create suitable space for their buildings. The question is, if they are allowed to use autoslope to do the terraforming. Theoretically they would be able to break the well known 'elevated tracks' that are build to block towngrowth or building of level-crossings.
Though the town will need some luck to do the right terraforming.

Autoslope without build-on-slopes:
Everyone agreed, that only autosloping under houses should be allowed.

Autoslope under light-houses and transmitters:
I agree that light-houses and transmitters only exist to annoy the player. So leave it this way. Autosloping will be disallowed.

Autoslope cost:
There are not a lot of responses. I will keep the current extra costs for building foundations. No cost depending on the building on the tile.

Local authority:
Hmm, tie. To my knowledge terraforming itself does not affect town ratings. Only killing involved trees does.
For now let it work like normal terraforming.
Roujin wrote:what is the clear tile cost of industries? is there any at all?
Yes, since magic bulldozer. I do not know the exact cost though.


Technical things:
NewHouses:
Check action 0 slope restrictions.

NewStations:
Decided later.

NewIndustries:
1. Autoslope is enabled by default.
2. If callback 2F is disabled, action 0 slope restrictions can deny autosloping. (In that case callback 3C will not be called)
3. Call callback 3C which can deny autosloping. Variable 60 represents the landscape that would result from the terraform operation (i.e. the new slope of the calling and neighboured tiles). If the callback fails, threat it like not enabled, i.e. allow autoslope.
DaleStan wrote:GRFs cannot cause desyncs. If your query-cost commands are changing things, then they are broken, not any GRF that they may query.
Do you suggest by that, that 7C variables should be treated read-only during query-cost commands?


Alternatively if autoslope is decided by a callback, assume 'allow autoslope' during query-cost/cost-estimation, and later fail during execution.
There are some things that act like this. (Like removing multiple houses at once, where only the first ones are removed, and the rating does not suffer for the remaining.)

Re: Yet another autoslope patch (90 percent complete)

Posted: 24 Aug 2007 15:55
by DaleStan
frosch wrote:
DaleStan wrote:GRFs cannot cause desyncs. If your query-cost commands are changing things, then they are broken, not any GRF that they may query.
Do you suggest by that, that 7C variables should be treated read-only during query-cost commands?
Hm... Not quite. That would break things. I'd say that the values should be stored before query, and restored afterward.

This prevents a GRF from tracking queries, which I would say is relatively useless anyway, in exchange for making things work elsewhere.

Re: Yet another autoslope patch (90 percent complete)

Posted: 05 Sep 2007 17:13
by MJS
The title of this topic says 90% complete - is that still valid? I guess many of us'd be glad to have some kind of autoslope in OTTD - especially those of us who switch from TTDPatch...

Re: Yet another autoslope patch (90 percent complete)

Posted: 05 Sep 2007 18:49
by AndersI
Don't you know that every project is 90% complete 90% of the time - the remaining 90% are needed to finish up...

Re: Yet another autoslope patch (90 percent complete)

Posted: 05 Sep 2007 22:57
by MJS
:D Yes, I know... it sounded promising, though, and one can always hope!