Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Sep 25, 2017 5:09 pm

All times are UTC




Post new topic  Reply to topic  [ 16 posts ] 
Author Message
PostPosted: Sat Sep 10, 2005 3:19 pm 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
I'm sure I've muttered about this before, but now I can't find it. Anyway, I'm going to make this suggestion official:

I think it would be useful to have callbacks for station naming, called on both the station and the closest industry (only if the closest industry is in the catchment area? Possibly all industries in catchment area, closest first?).
The return value would be either the number of a D0xx text, a magic number that maps to one of textIDs 300F..302F, or a magic number that means "revert to default naming".

It might also be useful to have a generic version of this callback, to be called if the station-specific and industry callbacks both fail. The main reason for this is to enable GRF-supplied strings for non rail-stations, but those probably belong in their own feature, so this may not be feasible.

Information that seems useful in this callback includes:
- Number of times this callback has been called, in case there are multiple GRF-supplied names.
- (industries, generic) Which station part is being built
- ΔX/ΔY from the station to the center of the nearest town (signed byte should be sufficient here; if it's more than 127 squares to the nearest town, the scenario creator should be shot.)
- ΔX/ΔY from the station to the nearest industry?
- (station, generic) type of nearest industry?

With this callback, Oz's megastations could name themselves appropriately, eg "\80 Grand Central", and MB's waypoints could name themselves "\80 Waypoint", &c.

The industry version of this callback would be useful for avoiding this type of illogicality:
cornelius wrote:
If you build a station next to a brewery it calls it "[town] Mines".
and for eg naming bouys near fishing grounds to "\80 Fishing Grounds".

_________________
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


Top
   
 Post subject:
PostPosted: Sat Sep 10, 2005 5:29 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Nov 27, 2004 3:05 pm
Posts: 4984
Location: Canada
I like this idea however I do have a question: Would the ability for a player to rename a station be preserved?

_________________
wallyweb on tt-forums: Screenshots - Projects - Releases
wallyweb on Simuscape: Projects - Releases
Other Stuff: TTDPatch 2.6 "Nightly" download - cirdan's OpenTTD branch (New Map Features)
Screenshot Of The Month Contest Winner: August 2015 - Tied May 2016


Top
   
 Post subject:
PostPosted: Sat Sep 10, 2005 5:46 pm 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
Of course. The callback should only be called when the station is first built; after that, the station would behave just like any other station.

This could also reduce the frequency of the "Too many stations/loading areas in this town" messages. I'm not sure if that's really a selling point, though; I've seen that message once.

_________________
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


Top
   
 Post subject:
PostPosted: Sat Sep 10, 2005 5:54 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 02, 2002 6:57 pm
Posts: 5552
Location: Ithaca, New York
Actually, this would allow something like a "more station names" set, that does nothing but add more predefined station names, that could be quite nice.

For that to work, it would need to be a generic stations callback, though, i.e. not one called for the specific station type that's being built.

_________________
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.


Top
   
 Post subject:
PostPosted: Sat Sep 10, 2005 6:03 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Nov 27, 2004 3:05 pm
Posts: 4984
Location: Canada
DaleStan wrote:
This could also reduce the frequency of the "Too many stations/loading areas in this town" messages. I'm not sure if that's really a selling point, though; I've seen that message once.

A definite selling point in a low number of towns scenario with many stations per town. Besides rail stations and waypoints, I often have several bus/lorry stations, remote airports, ports (docks) and now with Oskar's one way roads, on/off ramps for multilane highways, all in one town. Currently the only way around this is to rename stations which is fine. Your concept should ease this need significantly.

Another scenario: I build industrial parks containing several different industries serviced by one station. Retaining the ability to rename "Footown Steel Mill" to "Footown Industrial Park" would be a definite advantage for me.

_________________
wallyweb on tt-forums: Screenshots - Projects - Releases
wallyweb on Simuscape: Projects - Releases
Other Stuff: TTDPatch 2.6 "Nightly" download - cirdan's OpenTTD branch (New Map Features)
Screenshot Of The Month Contest Winner: August 2015 - Tied May 2016


Top
   
 Post subject:
PostPosted: Sat Sep 10, 2005 7:52 pm 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
I was hoping for both a station-specific and a generic callback, so that some strings could be applied only to certain stations, while other strings could be applied to any station.
The correct order to call the callbacks would probably be specific station, industry, generic station.

That is, ask the station if it has a specific name it wants, then ask the industry if nearby stations should have a specific name, then ask the generic handler for new station names.

wallyweb wrote:
Retaining the ability to rename "Footown Steel Mill" to "Footown Industrial Park" would be a definite advantage for me.

Under no circumstances should the presence of these callbacks disable station renaming. Even if I wanted to be able to disable station renaming, I seriously doubt that any patchteam member would code it.

I'm not quite sure how the call-count variable would work for the generic handler, assuming that they're chained. For the specific handlers, 02 04/0A 00 81 10 00 FF 02 00 FF 00 00 01 FF 01 01 FF FF will work just fine (assuming that the low byte of 10 contains the call count and FF is the return value for "fail") but for the generic handler, either even more Patch magic is required to set the counter correctly for each handler[0], or GRF magic is required to deal with an essentially random initial value for var 10.

It might also be useful to know:
- TextID (or at least the low byte thereof) to be used if the callback fails, or FF if no available string, so standard functionality can be preserved when desired.
Example: The first airport in a town is gets the default "\80 Airport", and the second gets "\80 International Airport"
- Town zone that the station is in (as for house var 42), so, eg "\80 Suburbs", doesn't appear smack in the middle of downtown.
- Some of the town variables (Population, mainly, but all would probably be easiest, with type 82/86/8A var 2s.)

The stationpart information should also include the airport type, and probably bus station vs. bus stop.

Whether the industry callback should be called with the industry's variables or the station's variables (assuming any of them are valid) is not clear to me.

[0] Possibly simpler: just call one handler until it fails, then reset and continue to the next one?

_________________
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


Top
   
 Post subject:
PostPosted: Sat Sep 17, 2005 4:51 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 02, 2002 6:57 pm
Posts: 5552
Location: Ithaca, New York
OK, I looked into this in a bit more detail now.

At the moment, TTD does something like the following ("try" means check if not used yet, if so use it and skip the remaining checks):
Code:
if (specialtype)   // buoy, docks, heliport, airport, oil field
    try corresponding name;
if (has mines nearby)    // coal, iron ore, copper ore, gold or diamond mine
    try "<townname> Mines";
if (less than 8 tiles from town center)
    try "<townname>", then "<townname> central"
if (close to water tile but not map edge)
    try "Lakeside";
if (close to trees or forest industry)
    try "Woods" ("Forest" in arctic climate);
if (station altitude below town center)
    try "Valley"
if (station altitude above town center)
    try "Heights";
if (station to the north, south, east or west of town center)
    try "North", "South", "East" or "West", respectively
try all remaining generic station names ("Transfer", "Halt", "Exchange", etc.)


So, the industries don't really play too much of a role here, except for the specific ones (mines or forests). I suppose I could look for nearby industries anyway, and call the callback for each of them still, but I'm not sure if that's really useful. Btw, the station part being built is probably not useful, since the naming only happens for the very first part built anyway, no matter how the player later arranges the station.

For the station callback, I could look at all nearby industry tiles, and create a bitmask of all industries present, that might be more useful. I'm not sure if any of the other properties are useful for this, like "is close to water", "is north/south/east/west", "is above/below town center" etc.

For the chained handler, all handlers in the chain would be called once for the first name, then for the second name, etc. until one doesn't fail. There's no problem with the callback count that way.

What I'm not sure about is what kind of text ID we should use here. If the callback handlers are to return a D0xx ID, I must allocate a custom text in TTD, of which there may be 512 I think. This would be one custom text for each station so named, not per type of station name.

Alternatively, it could be a DCxx ID, of which the grf would define one per type of station name. That's probably the better solution, but if the .grf is unloaded, the station would show "Text not available". Personally, I'd prefer this one I think.

_________________
Josef Drexler



TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker

No private messages please, you'll only get the answering machine there. Send email instead.


Top
   
 Post subject:
PostPosted: Sat Sep 17, 2005 5:17 pm 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
Patchman wrote:
Btw, the station part being built is probably not useful, since the naming only happens for the very first part built anyway, no matter how the player later arranges the station.

By "station part" I meant Airport/Heliport/RVbay/&c., so the generic callback could return "International Airport" only for large airports.

Patchman wrote:
[D0xx vs DCxx IDs]

Personally, I don't use custom texts very often, but I unload GRF files even less often. DCxx seems like a reasonable ID-space to use, although it does make the saves slightly less portable.

_________________
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


Top
   
 Post subject:
PostPosted: Wed Nov 16, 2005 1:38 am 
Offline
Graphics Moderator
Graphics Moderator
User avatar

Joined: Mon Sep 13, 2004 1:21 pm
Posts: 5184
Location: The Moon
*bump*

Patchman wrote:
if (has mines nearby) // coal, iron ore, copper ore, gold or diamond mine
try "<townname> Mines";
if (close to trees or forest industry)
try "Woods" ("Forest" in arctic climate);


At the moment, all newindustries seem to be "Mines".

Perhaps a new property could be added for industries; string to use for station names?

_________________
Pikkarail.com blog Image
Dev reference: NML Specs - NewGRF Specs - Savegame Internals - NoAi API - NoGo API
32bpp NewGRFs: Pineapple Trains (10cc) - Graphics Development


Top
   
 Post subject:
PostPosted: Wed Nov 16, 2005 1:51 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Oct 02, 2002 6:57 pm
Posts: 5552
Location: Ithaca, New York
PikkaBird wrote:
At the moment, all newindustries seem to be "Mines".


No, for example the fishing grounds don't. Since the search goes by industry tiles though, not actual industries (which don't really exist in the map), if a new industry overrides any mine tiles, it'll be considered a mine by this algorithm.

Quote:
Perhaps a new property could be added for industries; string to use for station names?


Which of the two types I suggested would you prefer?

_________________
Josef Drexler



TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker

No private messages please, you'll only get the answering machine there. Send email instead.


Top
   
 Post subject:
PostPosted: Wed Nov 16, 2005 2:01 am 
Offline
Graphics Moderator
Graphics Moderator
User avatar

Joined: Mon Sep 13, 2004 1:21 pm
Posts: 5184
Location: The Moon
Patchman wrote:
Since the search goes by industry tiles though, not actual industries (which don't really exist in the map), if a new industry overrides any mine tiles, it'll be considered a mine by this algorithm.


Ah, whoops, thanks, fixed! (in that order)

I guess then the new property would have to be for industry tiles, rather than industries?

Quote:
Which of the two types I suggested would you prefer?


Hmm... well the DCxx would seem to make most sense. Any game that was started with a newindustries grf which is no longer loaded is probably going to be unplayable anyway.

_________________
Pikkarail.com blog Image
Dev reference: NML Specs - NewGRF Specs - Savegame Internals - NoAi API - NoGo API
32bpp NewGRFs: Pineapple Trains (10cc) - Graphics Development


Top
   
PostPosted: Fri Nov 02, 2007 3:55 am 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
In about 5 minutes, industries can specify a string to be used for nearby stations instead of "<townname> Mines"/"<townname> Oilfield", or just that those strings not be used.

Getting the callbacks working will be much more interesting, though.


So far, I have this proposed spec, with almost zero clue on how to implement it.

Callback 14D
Called for Stations, Stations (generic)

During this callback, variable 10 is ??hhYYXX, and variable 18 is ????ppcc. The bytes are as follows:
YYXX: Signed ΔX and ΔY from the station to the center of the nearest town. If negative, the station is north of the town.
hh: Signed Δheight from the station to the center of the nearest town. If negative, the station is lower than the town.
pp: The station part being built. Low two bits 0..3 for feature. For features 0..2, bit 2 indicates:
0: WAYP vs anything else
1: trucks vs buses
2: dock vs bouy
For feature 3, remaining bits indicate airport type: 00..02 for small/large/heliport. Other values as Open sees fit; all bits set means "supplied by a newgrf".
cc: Call count. Each different call count should return a different result.

It might be possible to supply random bits somewhere, if necessary. Likely no station variables will be accessible; town variables may be accessible.

The return values are as follows:
00..FF Try the corresponding DCxx text for the station name.
100..120 Try the corresponding 300F..302F text for the station name.
121 For the station-specific callback, try the industry property/ies and then the generic callbacks.
121 For the generic callback, return to TTD's default station naming.
Here, as above, "try" means check if not used yet, if so use and skip remaining.

_________________
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


Top
   
PostPosted: Fri Nov 02, 2007 5:43 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Apr 16, 2003 4:09 pm
Posts: 4290
Skype: george-vb
Location: SPb, Russia.
DaleStan wrote:
In about 5 minutes, industries can specify a string to be used for nearby stations instead of "<townname> Mines"/"<townname> Oilfield", or just that those strings not be used.
How would it look for unowned station at fishing ground for example?

_________________
Image Image Image Image


Top
   
PostPosted: Fri Nov 02, 2007 6:01 am 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
The code or the result?
Since I modified the fishing grounds for my test anyway:
Code:
  -1 * 16    04 0A FF 01 80 DC 80 " Fishery" 00
<...>
  -1 * 88    00 0A 1A 01 1D 08 05 0B 02 0C 32 48 0D 35 48 0E 39 48 0F FF 10 04 0C 11 0C FF FF
           FF 12 00 13 00 14 05 15 04 34 39 44 48 16 FF FF FF 17 07 18 03 19 C0 1A 04 80 00 00 1B
           2D 48 1C 00 00 00 00 1D 00 00 00 00 1E 00 00 00 00 1F 75 DC 20 FF FF FF BF 21 BC 22 01
           24 80 DC


These are, like all property texts, DCxx or TTD texts, and not D0xx texts.


Attachments:
SCR3.PNG
SCR3.PNG [ 6.98 KiB | Viewed 2229 times ]

_________________
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
Top
   
PostPosted: Fri Nov 02, 2007 12:04 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Apr 16, 2003 4:09 pm
Posts: 4290
Skype: george-vb
Location: SPb, Russia.
DaleStan wrote:
The code or the result?
And what should happen if there are two industries nearby?

_________________
Image Image Image Image


Top
   
PostPosted: Fri Nov 02, 2007 3:11 pm 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
The exact same thing as if there are two oil rigs in the same town. Second one gets "North", "Valley", "Transfer", &c.. Whichever seems good to the TTD naming engine.

_________________
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 16 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.