[Patch] Industry Station Names (v1; r12436)

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

Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

[Patch] Industry Station Names (v1; r12436)

Post 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"...

Download:
industry_stationnames_v1_r12436.diff
industry stationnames v1 for r12436
(7.4 KiB) Downloaded 798 times
Screenshots:
with standard industries
with standard industries
stationnames_1.png (70.4 KiB) Viewed 29058 times
with newgrf industries
with newgrf industries
stationnames_2.png (91.01 KiB) Viewed 29061 times
---
older post:

Alpha 5 updated to revision 11859 (it was broken due to changes in trunk regarding unlimited custom names)
please read features and known bugs at this post:
http://www.tt-forums.net/viewtopic.php? ... 70#p653770

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 :/
Last edited by Roujin on 27 Mar 2008 00:11, edited 24 times in total.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [WIP] Industry Station Names

Post 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.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: [WIP] Industry Station Names

Post 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.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: [Patch] Industry Station Names (r11763)

Post by Roujin »

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

Changelog:
- Bug fixed: Town names don't work for standard town names.
- Change: changed radius to 4 tiles since AI loves to build stations 4 tiles away from industry (station coverage == 4 tiles aswell)

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.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
User avatar
rbenevid
Traffic Manager
Traffic Manager
Posts: 192
Joined: 14 Oct 2004 20:08
Location: Brazil

Re: [Patch] Industry Station Names (r11765)

Post 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!)".
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: [Patch] Industry Station Names (r11765)

Post 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.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: [Patch] Industry Station Names (r11765)

Post 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.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: [Patch] Industry Station Names (r11763)

Post by Bilbo »

Roujin wrote: - Change: changed radius to 4 tiles since AI loves to build stations 4 tiles away from industry (station coverage == 4 tiles aswell)
Not always. Bus/truck stops have only 3 tiles, dock have 5 tiles and large airports can have even larger coverage areas.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: [Patch] Industry Station Names (r11765)

Post 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
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: [Patch] Industry Station Names (r11765)

Post 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.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: [Patch] Industry Station Names (r11765)

Post 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.)
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: [Patch] Industry Station Names (r11765)

Post 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 ...
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: [Patch] Industry Station Names (r11765)

Post 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.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Re: [Patch] Industry Station Names (r11765)

Post 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, ...
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: [Patch] Industry Station Names (r11765)

Post 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)
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: [Patch] Industry Station Names (r11765)

Post 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.

includes:
- advanced terraform unify step (some minor improvements for terraforming)
- station delivered cargo (shows a "delivers" line in station placement window, like "accepts")
- industry station naming - numbering version (this patch)

enjoy.

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.
Attachments
patchpack_roujin_r12066.diff
Patch pack for r12066
Includes advanced_terraform_v3, station_supplies_v3 and industry_stationnames_v1
(50.2 KiB) Downloaded 543 times
patchpack_roujin_r12166.patch
Patch pack for r12166
Includes advanced_terraform_v3, station_supplies_v3 and industry_stationnames_v1
(51.18 KiB) Downloaded 608 times
patchpack_roujin_v2_r12320.diff
Patch pack v2 for 12320
Includes: adv.terraform v3, station supplies v3, industry stationnames v1, traffic lights alpha2.1, random road construction v1.
(85.61 KiB) Downloaded 644 times
Last edited by Roujin on 29 Feb 2008 21:56, edited 7 times in total.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: [Patch] Industry Station Names (r11765)

Post 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.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: [Patch] Industry Station Names (r12044)

Post by Roujin »

updated to r12044, see first post.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1729
Joined: 30 Mar 2005 09:43

Re: [Patch] Industry Station Names (r12044)

Post by peter1138 »

Still hooks directly into the string system :(
He's like, some kind of OpenTTD developer.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: [Patch] Industry Station Names (r12044)

Post by Roujin »

erm.. yes, sorry :oops: 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:
Revision: 12041
Author: belugas
Date: 04:23:26, Samstag, 2. Februar 2008
Message:
-Codechange: Add the loader and the property for action 00 industries, prop 24, nearby station name.
No assignation yet, no real work either.
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.. :?
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 9 guests