Station Name Patch?

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

User avatar
Salvo_guy
Traffic Manager
Traffic Manager
Posts: 128
Joined: 06 Jul 2006 06:40
Location: Somewhere Down Under

Station Name Patch?

Post by Salvo_guy »

I'm just asking if any1 knows where the station name "list" is kept, I'm looking to write a patch (or just edit the list) to have many stations in one "town"

If anyone know where the list is kept in the source code (if it is) or how i'd go about over-riding it?
User avatar
Toni Babelony
Tycoon
Tycoon
Posts: 1389
Joined: 07 Jul 2006 09:34
Skype: toni_babelony
Location: Sagamihara-shi, Japan
Contact:

Post by Toni Babelony »

True, I'm getting annoyed by the "Centre, Woods, Mines, Lower, Upper, etc." additions to the town name... I usually replace names with my own imagination, but it takes quite some time when you have a huge commuter network lying around a city... :?
Retired JapanSet developer and creator of TIAS.
User avatar
mart3p
Tycoon
Tycoon
Posts: 1030
Joined: 31 Oct 2005 21:00
Location: UK

Re: Station Name Patch?

Post by mart3p »

Salvo_guy wrote:I'm just asking if any1 knows where the station name "list" is kept, I'm looking to write a patch (or just edit the list) to have many stations in one "town"

If anyone know where the list is kept in the source code (if it is) or how i'd go about over-riding it?
Well the “list” is in english.txt and in all the other language files for other languages. But I think what your looking for is the function GenerateStationName in station_cmd.c.

Just one small point, I found when I started my first patch for OTTD, that a good way to learn the code is to search for things yourself ;) .
Image
User avatar
sidew
Engineer
Engineer
Posts: 115
Joined: 31 Aug 2005 06:46
Location: Milan, Italy
Contact:

Re: Station Name Patch?

Post by sidew »

mart3p wrote: Just one small point, I found when I started my first patch for OTTD, that a good way to learn the code is to search for things yourself ;) .
I agree. This is I started when I wrote my Italian town generator patch
Sidewinder

Italian Town names patch for OTTD (R5266) now in trunk since 0.4.8
For typo, errors or bug on OTTD italian translation, please PM me.
unofficial italian TTD/OpenTTD forum: http://wolf01.game-host.org/forum/index.php
Hazelrah
Traffic Manager
Traffic Manager
Posts: 196
Joined: 13 Apr 2005 05:41

Post by Hazelrah »

I third that statement.

I also found that looking at patch files to see how the portion of the code I was interested in was also a fantastic way to get to know the code I cared about. Even if you don't speak Italian, if your interested in changing town name generation, I recommend that you look at the Italian names generation patch too.

-Hazelrah
User avatar
Salvo_guy
Traffic Manager
Traffic Manager
Posts: 128
Joined: 06 Jul 2006 06:40
Location: Somewhere Down Under

Post by Salvo_guy »

Okay... so i've found the code i'm looking for... and what i'm planning to do is basically recode the entire function... but i don't really understand it that well... is there a way/place i can teach myself?
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

Salvo_guy wrote:Okay... so i've found the code i'm looking for... and what i'm planning to do is basically recode the entire function... but i don't really understand it that well... is there a way/place i can teach myself?
Well, best thing is just to experiment; try something, see if it works, if not, modify, repeat until perfect ;)
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
User avatar
Salvo_guy
Traffic Manager
Traffic Manager
Posts: 128
Joined: 06 Jul 2006 06:40
Location: Somewhere Down Under

Post by Salvo_guy »

okay... well that "seems" like a good idea... but i guess thats what i tell others when they need help from me... oh well... hopefully i'll have a ptach soon... (for those who want it)
User avatar
Salvo_guy
Traffic Manager
Traffic Manager
Posts: 128
Joined: 06 Jul 2006 06:40
Location: Somewhere Down Under

Post by Salvo_guy »

so the code i wrote compiles... now i just got a stupid winsock2.h error and the one that goes with it...
User avatar
Salvo_guy
Traffic Manager
Traffic Manager
Posts: 128
Joined: 06 Jul 2006 06:40
Location: Somewhere Down Under

Post by Salvo_guy »

okay... i'm completely stuffed...

this is my code:

CODE: (starting line 333)
#define M(x) ((x) - STR_SV_STNAME)
int stnum = 1
#define Str_stnum == stnum
static bool GenerateStationName(Station *st, TileIndex tile, int flag)
{
static const uint32 _gen_station_name_bits[] = {
0, /* 0 */
1 << M(STR_SV_STNAME_AIRPORT && str_stnum) , /* 1 */
1 << M(STR_SV_STNAME_OILFIELD && str_stnum) , /* 2 */
1 << M(STR_SV_STNAME_DOCKS && str_stnum) , /* 3 */
0x1FF << M(STR_SV_STNAME_BUOY_1), /* 4 */
1 << M(STR_SV_STNAME_HELIPORT && str_stnum) , /* 5 */


And this is the error...

ERROR:

station_cmd.c
c:\openttd(source)\station_cmd.c(336) : error C2143: syntax error : missing ';' before 'type'
c:\openttd(source)\station_cmd.c(336) : error C2059: syntax error : 'type'
c:\openttd(source)\station_cmd.c(1041) : warning C4013: 'GenerateStationName' undefined; assuming extern returning int
TrueSatan
Transport Coordinator
Transport Coordinator
Posts: 291
Joined: 16 Jul 2003 18:33

Post by TrueSatan »

hi.
in stnum = 1 ? missing ;
outside everything. how should this work ? ;-)
User avatar
Salvo_guy
Traffic Manager
Traffic Manager
Posts: 128
Joined: 06 Jul 2006 06:40
Location: Somewhere Down Under

Post by Salvo_guy »

well it "should" just add a number onto the end of each station name...

although i could b wrong (thats just how i want it) btw this is my first attempt at any type of coding... etc so it doesn't run out of names... (in theory)
TrueSatan
Transport Coordinator
Transport Coordinator
Posts: 291
Joined: 16 Jul 2003 18:33

Post by TrueSatan »

hi again.
yes i know what you've wanted to do. but this way it's not working ;-)
i'm not really a programmer myself, but i've got my few patch codes working so far.

if you want to define a variable outside you could try
static int _stnum = 1;
don't forget to do the semicolon after the int static int etc.
that's why your compiler complaint about missing ';' before type :-)

read other parts of the code, i've done the same for my patches.
maybe you'll find similar functions in the code.
i'm not sure if this defining a variable outside a function is a good solution
and if your modification works.
but there are others here with more programming experience. i'm sure they will help you if you ask them. also try the irc channel.

i'm sure you'll get a working patch if you keep up your work :-)
User avatar
glx
OpenTTD Developer
OpenTTD Developer
Posts: 623
Joined: 02 Dec 2005 15:43
Location: Drancy(93) - France
Contact:

Post by glx »

The line

Code: Select all

#define Str_stnum == stnum
is wrong. And there's a missing ';' as TrueSatan said.
User avatar
Salvo_guy
Traffic Manager
Traffic Manager
Posts: 128
Joined: 06 Jul 2006 06:40
Location: Somewhere Down Under

Post by Salvo_guy »

Would it be worth altering the waypoint naming system to suit stations... and would there b any major hassles with doing so... (have been trying for about 2 weeks now still no progress)
l_Blue_l
Transport Coordinator
Transport Coordinator
Posts: 285
Joined: 29 Mar 2006 22:42
Contact:

Post by l_Blue_l »

i know how you feel. i have been trying to get a station provides thing to work when your building a station and have tried atleast 3 differnt ways and none have worked. i think i will give up on it for awhile and come back to it in a couple of weeks with a fresh mind.

This weekend i will have a look at the station naming and waypoint naming to see if i can give you any ideas on the subject.
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

Why add a number to station names? Why not add station new station names?
They are defined in the lang files around 1900.

Maybe you need to code something to get them used.
User avatar
Salvo_guy
Traffic Manager
Traffic Manager
Posts: 128
Joined: 06 Jul 2006 06:40
Location: Somewhere Down Under

Post by Salvo_guy »

i was thinking of making it an option so that you could either use the normal station names... or the extended list of "town names with numbers"

also so that you can have a larger map with lesser towns... and more stations (i prefere to use freight trains more than passenger ones)
l_Blue_l
Transport Coordinator
Transport Coordinator
Posts: 285
Joined: 29 Mar 2006 22:42
Contact:

Post by l_Blue_l »

Code: Select all

	
tmp = free_names & ((1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<6)|(1<<7)|(1<<12)|(1<<26)|(1<<27)|(1<<28)|(1<<29)|(1<<30));
	if (tmp == 0) {
		- _error_message = STR_3007_TOO_MANY_STATIONS_LOADING;
		- return STR_SV_STNAME ;
		
		+found = M(STR_0130_RENAME);
		+goto done;
The message of TOO MANY STATIONS are gone forever with this but this basicaly forces you to Rename the Stations if i knew alittle more about how strings work i would beable to do something better but currently i know very little about strings.
Attachments
Station named Rename when over the set limit of station names.
Station named Rename when over the set limit of station names.
Rename.PNG (137.37 KiB) Viewed 7267 times
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

l_Blue_l wrote:

Code: Select all

	
....
The message of TOO MANY STATIONS are gone forever with this but this basicaly forces you to Rename the Stations if i knew alittle more about how strings work i would beable to do something better but currently i know very little about strings.
Could you change that code above to a that what svn diff would create, or create a diff file by using svn diff.

How about asking other people things about the string usage in openttd? But there is no question so i do not answer anything. I think others will to it the same way, so feel free to ask :)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 12 guests