Page 1 of 1

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

Posted: 21 Sep 2009 23:17
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 :)

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

Posted: 21 Sep 2009 23:24
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.

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

Posted: 21 Sep 2009 23:44
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

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

Posted: 22 Sep 2009 00:05
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.

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

Posted: 22 Sep 2009 08:06
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.

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

Posted: 22 Sep 2009 10:29
by crakinshot
Yeah, I wouldn't recommend using this project as a way to learn C/C++ from the beginning.

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

Posted: 22 Sep 2009 12:57
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?

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

Posted: 22 Sep 2009 12:59
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.

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

Posted: 22 Sep 2009 13:10
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?

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

Posted: 22 Sep 2009 19:48
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

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

Posted: 22 Sep 2009 20:45
by matthew1989
looking back it was a bit old... probs not work in new trunk anywho :P

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

Posted: 23 Sep 2009 19:17
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.

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

Posted: 24 Sep 2009 19:48
by 555gln22
Would it be worth going way, way back to see how trams were added?

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

Posted: 25 Sep 2009 23:11
by matthew1989
might be worth a go, any ideas where to look tho?

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

Posted: 26 Sep 2009 14:23
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?

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

Posted: 26 Sep 2009 14:41
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.

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

Posted: 26 Sep 2009 14:43
by matthew1989
thank you, was there any previous patches?

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

Posted: 28 Sep 2009 00:17
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

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

Posted: 28 Sep 2009 10:59
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.

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

Posted: 28 Sep 2009 11:07
by FHS
Good luck for Tomorrow

Regards
FHS