Adding More Roadtypes (motorways/highways/trails etc.)

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

Post Reply
matthew1989
Engineer
Engineer
Posts: 31
Joined: 19 Sep 2009 19:31

Adding More Roadtypes (motorways/highways/trails etc.)

Post by matthew1989 »

im trying to compile openttd in VB c++ express 2008 and im getting errors from this section of code, it seems to think there should be a ',' before the ')'. this is from ROADMAP.H


static inline RoadBits GetOtherRoadBits(TileIndex t, RoadType rt)
{
return GetRoadBits(t, rt == ROADTYPE_ROAD ? ROADTYPE_TRAM ? ROADTYPE_HWAY : ROADTYPE_ROAD );
}

any help would be appreciated :)
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by Yexo »

What version are you trying to compile? In trunk that function looks like this:

Code: Select all

static inline RoadBits GetOtherRoadBits(TileIndex t, RoadType rt)
{
	return GetRoadBits(t, rt == ROADTYPE_ROAD ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
and it compiles fine.
matthew1989
Engineer
Engineer
Posts: 31
Joined: 19 Sep 2009 19:31

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by matthew1989 »

Yexo wrote:What version are you trying to compile? In trunk that function looks like this:

Code: Select all

static inline RoadBits GetOtherRoadBits(TileIndex t, RoadType rt)
{
	return GetRoadBits(t, rt == ROADTYPE_ROAD ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
and it compiles fine.
i've modified the source to allow me to add a third roadtype (ROADTYPE_HWAY and ive added it next to the ROADTYPE_ROAD ? ROADTYPE_TRAM with a '?', is this right? and i've modified the latest trunk

sorry, im just learning C++ and thought learning it would be easier than it has turned out to be :P
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by Yexo »

matthew1989 wrote:i've modified the source to allow me to add a third roadtype (ROADTYPE_HWAY and ive added it next to the ROADTYPE_ROAD ? ROADTYPE_TRAM with a '?', is this right? and i've modified the latest trunk

sorry, im just learning C++ and thought learning it would be easier than it has turned out to be :P
Aha, ok :). The modification you did was not correct, but without more information on your other changes I cannot give you the correct way to change this function. The best advice (yes, you've probably heard it before) is to learn coding first, then try to understand the OpenTTD code. OpenTTD is a pretty big project and without any coding experience it's hard to understand / modify.
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by CommanderZ »

Yexo wrote:
matthew1989 wrote:i've modified the source to allow me to add a third roadtype (ROADTYPE_HWAY and ive added it next to the ROADTYPE_ROAD ? ROADTYPE_TRAM with a '?', is this right? and i've modified the latest trunk

sorry, im just learning C++ and thought learning it would be easier than it has turned out to be :P
Aha, ok :). The modification you did was not correct, but without more information on your other changes I cannot give you the correct way to change this function. The best advice (yes, you've probably heard it before) is to learn coding first, then try to understand the OpenTTD code. OpenTTD is a pretty big project and without any coding experience it's hard to understand / modify.
I think otherwise, OTTD is great place to learn about C++ in deep. But you have to know the very basics (=syntax) first.
User avatar
crakinshot
Engineer
Engineer
Posts: 62
Joined: 14 Sep 2009 14:31
Location: North Wales

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by crakinshot »

Yeah, I wouldn't recommend using this project as a way to learn C/C++ from the beginning.
matthew1989
Engineer
Engineer
Posts: 31
Joined: 19 Sep 2009 19:31

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by matthew1989 »

i gathered that the hard way :P

im going college next year to learn programming, but i kinda wanted to learn from OTTD :P
is there any work or patches going into the 3rd roadtype?
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by Gremnon »

There was a project a while back, as I recall, that added a kind of dirt-track road type, but if I remember right, there was never any patches or code released for it.
matthew1989
Engineer
Engineer
Posts: 31
Joined: 19 Sep 2009 19:31

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by matthew1989 »

i saw that patch idea, but if im correct, the pathfinder and the road gui and the newgrfs would need changing to allow use of the new roadtype. is this a major roadblock? or is it easy enough to re-code?
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by Roujin »

The patch in question (trails) was made by me, but unfortunately I never released it and on top of that I've lost the code.. :( sorry
* @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
matthew1989
Engineer
Engineer
Posts: 31
Joined: 19 Sep 2009 19:31

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by matthew1989 »

looking back it was a bit old... probs not work in new trunk anywho :P
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by Roujin »

Still, it could've given you some hints as to where to change what.
But as I said, I've lost it, unfortunately. Sorry.
* @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
555gln22
Engineer
Engineer
Posts: 120
Joined: 09 Sep 2008 19:48

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by 555gln22 »

Would it be worth going way, way back to see how trams were added?
Formerly known as 'davepoth'
matthew1989
Engineer
Engineer
Posts: 31
Joined: 19 Sep 2009 19:31

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by matthew1989 »

might be worth a go, any ideas where to look tho?
matthew1989
Engineer
Engineer
Posts: 31
Joined: 19 Sep 2009 19:31

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by matthew1989 »

can somebody point me to either a TRAM patch (before it was implemented into trunk) or the revision where trams were first included?
User avatar
FHS
Director
Director
Posts: 577
Joined: 18 Apr 2009 17:17
Location: Basel, CH

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by FHS »

matthew1989 wrote:can somebody point me to either a TRAM patch (before it was implemented into trunk) or the revision where trams were first included?
The first revision to feature tram support was r9923.
matthew1989
Engineer
Engineer
Posts: 31
Joined: 19 Sep 2009 19:31

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by matthew1989 »

thank you, was there any previous patches?
matthew1989
Engineer
Engineer
Posts: 31
Joined: 19 Sep 2009 19:31

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by matthew1989 »

Just to update this, im currently studying the OLD revisions to work out how trams were added.
Played on the European scenarion and decided we DEFINATLY need highways. However, my daughter is due to be born tomorrow, so i've got a bit of work there, afterall, training her to play OTTD won't be easy for her :P
User avatar
tsjook
Traffic Manager
Traffic Manager
Posts: 197
Joined: 22 Apr 2009 18:33

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by tsjook »

Good luck during the next day. Hope all will go well!
matthew1989 wrote:Played on the European scenarion and decided we DEFINATLY need highways.
So true.
User avatar
FHS
Director
Director
Posts: 577
Joined: 18 Apr 2009 17:17
Location: Basel, CH

Re: Adding More Roadtypes (motorways/highways/trails etc.)

Post by FHS »

Good luck for Tomorrow

Regards
FHS
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 6 guests