Transport Tycoon Forums

[Patch] Industry Station Names (v1; r12436)

[Patch] Industry Station Names (v1; r12436)

Posted: 04 Jan 2008 08:09

by Roujin

I've decided to drop the version with numbering, now it will only name one station after this scheme and then fall back to default names.
No new features, just updated to current trunk and renamed to "v1"...

I made two versions - the "nonumbering" one names only the one station after the industry, after that falls back to normal OTTD station naming.

With numbering:

Without numbering:

Screenshots:

---
Just a little information for everyone: There is a newGrf feature that will probably make this patch somewhat obsolete once it is implemented in OpenTTD. See http://wiki.ttdpatch.net/tiki-index.php ... station_24_
Belugas told me that seeing my little patch here inspired him to go work on that - I don't know how complicated that matter is, but maybe soon you will see something in trunk that will make this patch useless.

Until then, you're free to use this little patch, but don't expect it to be included in trunk for the reason i just stated.
---

original post:
---

Hi everyone,

I am currently working on a little patch that changes station naming: when built near an industry, the station will be named after it.

For example there's a city called Slundington, and it has a Coal Mine, namely Slundington Coal Mine. A station built within three tiles of the industry will automatically be named "Slundington Coal Mine".

This is compatible with any newgrf industries. If you have an ECS Machinery Vector loaded that defines Vehicle factories, you will be able to get a station called "Slundington Vehicles factory" and so on...

The patch is currently WIP, I have to deal with some stuff I appearently can't solve right now, but soon I'll post a first alpha version and I'd appreciate if you comment on my idea.
I hope someone else likes this idea; i always found the built-in station naming "Woods", "Mines" and so on not exact enough for my likes, so i got this idea.

---
In my current build the stations are already named after the industry correctly, but the town names give me some trouble if they are generated ones (not set by hand).

If anyone experienced with OTTD coding could give me a quick hand.. how can I get the name of a Town Object properly as a string? I found no function that would help me :/

Re: [WIP] Industry Station Names

Posted: 04 Jan 2008 08:38

by planetmaker

I think it's a great idea and is exactly the naming convention I apply at those times when I care about names (e.g. when things get more complex). Eager to see results.

Re: [WIP] Industry Station Names

Posted: 04 Jan 2008 10:03

by Roujin

okay, first alpha version is here.

Features:
- Station naming after Industries that are near. (Currently this has almost highest naming priority, only standard names "Airport", "Docks" etc. are higher. This may change sometime)
- Is a name already taken, it will append a "2", "3" and so on, up to "9" (e.g. "Coal Mine 2"). After that, it will fall back to the usual names.

Known bugs:
- Town Name does NOT work yet for standard named towns. The stations should right now be called "Coal Mine", "Coal Mine 2", and so on. However IF you change a town name to something user defined, the naming should also include the town name from then on: "[Town] [Industry] [Number(optional)]"
- It is not yet checked if a generated name is too long (resulting from long town and/or industry name). In this case the name will just be cut off at the end. This can result in multiple stations with the same name, which is normally prohibited.

If you encounter any behavior differing from what i described or any bugs other than i mentioned, please report. Also, if you are experienced with OTTD coding, i could use a hint on how to get the name from a town :/

Thanks, download is in first post.

Re: [Patch] Industry Station Names (r11763)

Posted: 05 Jan 2008 22:23

by Roujin

again changed something, newest version is alpha 4. (download in first post)

Features:
- Station naming after an Industriy that is near (<= 4 tiles away). It will be named after the following scheme: "[Town name] [Industry name]"
- If a name is already taken, it will append a "2", "3" and so on, up to "9" (e.g. "Slundborough Coal Mine 2"). After that, it will fall back to the usual names.
- It works with all languages and newgrf Industries

Known bugs:
- It is not yet checked if a generated name is too long (resulting from long town and/or industry name). In this case the name will just be cut off at the end. This can result in multiple stations with the same name, which is normally prohibited.
- The surrounding 4 tiles are checked only beginning from the northeastmost tile (that is how it's handled by original code, tho)

Notes:
- Take note that the station will not be named after the nearest town, but the town the industry in question belongs to and is named after. This should normally be the same town though.
- The station names are static. This means if you change the name of the town the industry belongs to, or change the game language while playing so the industry has another name, the station names generated by this patch will NOT update to the changes.

Credits:
Thanks to Noldo for your kind help.
----------

If you encounter any bugs not listed or otherwise strange behavior; or if you have a feature request, please post it.

And a little information for everyone: There is a newGrf feature that will probably make this patch somewhat obsolete once it is implemented in OpenTTD. See http://wiki.ttdpatch.net/tiki-index.php ... station_24_
Belugas told me that seeing my little patch here inspired him to go work on that - I don't know how complicated that matter is, but maybe soon you will see something in trunk that will make this patch useless.

Until then, you're free to use this little patch, but don't expect it to be included in trunk for the reason i just stated.

Re: [Patch] Industry Station Names (r11765)

Posted: 06 Jan 2008 00:31

by rbenevid

Nice patch! I hope it gets in the trunk even if the grf feature is implemented (for when you're not using
ECS/PBI).

A suggestion: have an option so that if there's already a station with that name, normal TTD naming
takes over? First station "Slunn Coal Mine", second "Slunn Heights/Valley/Transfer/whatever(not Mines!)".

Re: [Patch] Industry Station Names (r11765)

Posted: 06 Jan 2008 04:32

by Roujin

okay, alpha 5 is released (download in first post)
I made two versions of it - the one with "nonumbering" in its filename does what you suggested, rbenevid.

Changelog:
- Bug fixed: It was not checked if a generated name is too long; that could lead to multiple stations with the same name.
- Bug fixed: the tile check only checked 4 tiles each direction starting from the northeasternmost tile of the station. Now it checks 4 tiles in each direction with the whole station as center (makes a difference for big railway stations and airports)
(- Change: in "nonumbering" version, no more numbering of stations, just one per industry)

Features:
- Station naming after an Industry that is near (<= 4 tiles away). It will be named after the following scheme: "[Town name] [Industry name] [Number]*"
*Number only for number >= 2; "nonumbering" version disables numbers altogether
- It works with all languages and newgrf Industries

Known bugs:
- For docks, it doesn't check the 4 tiles radius with the whole dock as center yet, but only with land tile as center.

Notes:
- Take note that the station will not be named after the nearest town, but the town the industry in question belongs to and is named after. This should normally be the same town though.
- The station names are static. This means if you change the name of the town the industry belongs to, or change the game language while playing so the industry has another name, the station names generated by this patch will NOT update to the changes.

Credits:
Thanks to Noldo for your kind help.
----------

If you encounter any bugs not listed or otherwise strange behavior; or if you have a feature request, please post it.

Re: [Patch] Industry Station Names (r11765)

Posted: 06 Jan 2008 07:26

by DaleStan

Roujin wrote:- The station names are static. This means if you change the name of the town the industry belongs to, or change the game language while playing so the industry has another name, the station names generated by this patch will NOT update to the changes.

You should be able to borrow the "{TOWN} {INDUSTRY}" text, and add a "{TOWN} {INDUSTRY} {NUMBER}" text, in order to fix those two issues. And to no longer consume the quite limited custom-texts space.

Re: [Patch] Industry Station Names (r11763)

Not always. Bus/truck stops have only 3 tiles, dock have 5 tiles and large airports can have even larger coverage areas.

Re: [Patch] Industry Station Names (r11765)

Posted: 06 Jan 2008 19:19

by Roujin

@Bilbo: That again depends on your patch settings

Well, the proper way to make it were checking the acceptance tiles for industry. That would also nullify the need to make another ugly hack for the dock. (see known bugs) :rolly: I'll make a note of that for a possible future version.

(but this patch here is halted right now because i'm working on another one)
---
Feature Requests:
- Use StringIDs instead of custom text
- Replace the static check radius by a check over the station's acceptance tiles

Re: [Patch] Industry Station Names (r11765)

Posted: 07 Jan 2008 06:58

by Bilbo

DaleStan wrote:

Roujin wrote:- The station names are static. This means if you change the name of the town the industry belongs to, or change the game language while playing so the industry has another name, the station names generated by this patch will NOT update to the changes.

You should be able to borrow the "{TOWN} {INDUSTRY}" text, and add a "{TOWN} {INDUSTRY} {NUMBER}" text, in order to fix those two issues. And to no longer consume the quite limited custom-texts space.

I wonder how often are such dynamic texts resoved - if resolving the {INDUSTRY} part would be costly and strings got resoved much more than once per map, we may have some performance degradation.

But still the string could be at least something like "{TOWN} Mines {NUMBER}". Ideal would be to unlimit the limited custom-texts space, but I am not sure how easy/hard would that be.

Re: [Patch] Industry Station Names (r11765)

Posted: 07 Jan 2008 07:17

by DaleStan

Bilbo wrote:But still the string could be at least something like "{TOWN} Mines {NUMBER}".

Except that there would then have to be a nearly infinite number of such names, since newindustries can specify a nearly infinite number of names for an industry. (I think the theoretical limit is somewhere around 97^65525. And yes, I got those numbers in the correct order; the larger one is the exponent.)

Re: [Patch] Industry Station Names (r11765)

Posted: 07 Jan 2008 08:05

by Bilbo

DaleStan wrote:

Bilbo wrote:But still the string could be at least something like "{TOWN} Mines {NUMBER}".

Except that there would then have to be a nearly infinite number of such names, since newindustries can specify a nearly infinite number of names for an industry. (I think the theoretical limit is somewhere around 97^65525. And yes, I got those numbers in the correct order; the larger one is the exponent.)

So there is limit of 65525 characters? Well, you'll run out of RAM anyway somewhere around 97^5 so the limit is really theoretical, also you have lower limit 2^32 or 2^64 depending on CPU architecture. And you can't stuff more than about million stations on 2048*2048 map anyway ...

Re: [Patch] Industry Station Names (r11765)

Posted: 07 Jan 2008 14:14

by DaleStan

The actual limit is that an action 4, in total, cannot exceed 65535 bytes. I was figuring about 10 bytes of overhead, leaving about 65525 for the name. But I did forget about the printables in the 80..FF range.

The point is that you cannot put things that can be set by newgrf in the language files, because you cannot possibly get all the possibilities into the language file.

Re: [Patch] Industry Station Names (r11765)

Posted: 07 Jan 2008 23:07

by athanasios

Reading all the posts, I am urged to request the following:
Can something similar be done with industries?
EG: London Coal Mine A, London Coal Mine B, ...

Re: [Patch] Industry Station Names (r11765)

Posted: 08 Jan 2008 00:58

by Bilbo

DaleStan wrote:The point is that you cannot put things that can be set by newgrf in the language files, because you cannot possibly get all the possibilities into the language file.

No, but as I saw some support for localized messages in some parts of NewGRF specs (so newGRF author can stuff localized messages in the file, although he is unlikely to have localization for all 39 languages available in openttd or 13 or so available in TTDPatch)

Re: [Patch] Industry Station Names (r11765)

Posted: 10 Jan 2008 13:36

by Roujin

erm.. appearently I messed around with the .diff that has numbering and broke it before uploading. I'll reupload a fixed .diff for newest revision some time later or tomorrow.. now i only have a combined diff with all 3 of my patches currently in development for r11804.

edit: new patch pack for r11861.
edit: new patch pack for r11929.
edit: new patch pack for r11987.
edit: new patch pack for r12036.
edit: new patch pack for r12066.
edit: new patch pack (thanks to Gonozal) for r12166.
edit: patch pack version 2 for r12320.

Re: [Patch] Industry Station Names (r11765)

Posted: 15 Jan 2008 11:23

by Roujin

updated the patch to revision 11859. (old version was broken since the naming stuff was changed severely in trunk - now unlimited number of custom station/town/etc. names are possible)

download in first post.

Re: [Patch] Industry Station Names (r12044)

Posted: 03 Feb 2008 14:57

by Roujin

updated to r12044, see first post.

Re: [Patch] Industry Station Names (r12044)

Posted: 04 Feb 2008 07:35

by peter1138

Still hooks directly into the string system

Re: [Patch] Industry Station Names (r12044)

Posted: 04 Feb 2008 08:27

by Roujin

erm.. yes, sorry Haven't had time to look into how I could make this properly. Worked more on my other patches than on this. At the moment this is just "working", far from being "proper" or "clean"...
Actually I don't know if I want to invest time in this patch since there is action 00 industries, prop 24 - nearby station names. And at least the foundation for its implementation is already in trunk now:

I'm thinking of that as the more sophisticated implementation of the same idea (naming station after nearby industry), so once that's here I think it will kind of depreciate my patch - that's why i'm reluctant to making this properly in the beginning..