News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Auto factory rotation capability

Started by wlindley, August 02, 2021, 07:22:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wlindley

This patch adds a functional Auto rotation option in the factory creation dialog, and always auto-rotates consumer industries during world creation. The result is much-nicer looking cities. 


jamespetts

Now incorporated, thank you.

I do notice that sometimes industries on map generation are not always rotated in the same direction vis a vis a road, however, and that there are occasions on which industries seem to be connected to a road only diagonally. Is this the intended behaviour?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

wlindley

The algorithm only checks the adjacent tiles due north, south, east, west, so diagonal roads are indistinguishable from square ones.  Also, bridges are of waytype other then 'road' so are not counted; and if no actual road waytype is adjacent, the random rotation is used.  This is imperfect and I hope to devise better.

Matthew

This is a great new feature!  :) Thank you, wlindley!

I played about with this earlier today and although it seems to work as intended, I wonder whether James' observations could be explained by the following assumptions?

Urban factory entrances must face south on rotation 0
The code seems to assume that factories will be drawn with the road entrance facing south on rotation 0. In pak128.Britain-Ex, I think all of the single-tile factories observe this rule, except for the fishing port which is oriented to the water (and is a different kettle of fish....  ;D ). However, there are several multi-tile factories where the factory gate has not been drawn with the road entrance facing south on rotation (0). So the entrance does not appear where the code expects it to.

The easiest way to fix this would be for each pakset project to rename affected .png files so that the road entrance does indeed face south on rotation 0. This would visually alter existing savegames (such as the demo.sve game), but I don't remember anyone complaining when wlindley kindly redrew some of the factories last year, so it should be fine. It would be a one-off project that could be done in an hour or two and there is no urgency.

Factories cannot be built, but the error is not explained
If you try to use the Build Factory tool to build a rectangular (e.g. 2x1) factory to the east or west of an urban road, then I think the code tries to re-orient it so that the south side of rotation 0 is oriented to the road, which changes it to a 1x2 shape. If existing objects stop the factory being placed by a such, it seems that the tool silently fails to build. This might well be an existing issue rather than a regression, but this is not yet a formal bug report as I need to test more.

Rural factories are not oriented
This code does not seem to be called if the game builds factories outside towns. Fixing this might be a more complex project as it involves interaction between this code (which assumes the road entrance is drawn on the south) and the code that builds roads to factories (which builds to the NW corner of the factory). Probably not worth it.

Extension request: autorotation for multi-tile city buildings?
I have a half-finished project to add some multi-tile city buildings (courts) to pak128.Britain-Ex. One of the reasons it isn't finished is that the buildings' road entrances aren't oriented to the roads, which looks awful. I would be very grateful if this code could be added to the citybuilding code please, perhaps only to citybuildings that are flagged in their .dat file (e.g. apply_auto_rotation=1). However, at the moment I think that Standard and Extended have different version of the multi-tile citybuilding code and it's possible that the Standard code already has this (I remember it being discussed; I don't know what the conclusion was).
(Signature being tested) If you enjoy playing Simutrans, then you might also enjoy watching Japan Railway Journal
Available in English and simplified Chinese
如果您喜欢玩Simutrans的话,那么说不定就想看《日本铁路之旅》(英语也有简体中文字幕)。

prissi

Standard does auto rotation of multitile city buildings and correct divers bugs of the original multitile citybuildign code ...