The big picture and mentoring

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
luxtram
Transport Coordinator
Transport Coordinator
Posts: 344
Joined: 10 May 2016 19:09

The big picture and mentoring

Post by luxtram »

I hope that somebody can be kind enough to point me to the information that describes the running of the game on the general level.

I am looking for something that would give me the big picture of the code so I could have a starting point to thread into the code base.

Perhaps somebody is also willing to do some mentoring to help to get going.
California City Sets viewtopic.php?t=76786
1000 building set viewtopic.php?t=75250
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: The big picture and mentoring

Post by Eddi »

not sure what you're aiming for here. you won't find a person who has read every single piece of the code.

if your aim is to "get your feet wet", then maybe look at the github category for "good first issue". otherwise, you get a "big picture" usually by getting lots of smaller pictures, e.g. by looking up what other people have done.
luxtram
Transport Coordinator
Transport Coordinator
Posts: 344
Joined: 10 May 2016 19:09

Re: The big picture and mentoring

Post by luxtram »

Eddi wrote:not sure what you're aiming for here. you won't find a person who has read every single piece of the code.
Mainly the big picture = broad architecture of the game, how things come together.

For example where is the main game cycle defined (that runs through all the items and makes them do what they should do)? Or there appears to be a naming convention like _cmd, _gui, _func etc, what is the function of such files? And so on.
Eddi wrote:otherwise, you get a "big picture" usually by getting lots of smaller pictures, e.g. by looking up what other people have done.
This is exactly what I am trying to avoid to do. I do not want reverse engineer the the game architecture. It would take me unreasonable amount of time (that I do not have much to spend).

Knowing the architecture would give tremendous help for figuring out the small parts.
California City Sets viewtopic.php?t=76786
1000 building set viewtopic.php?t=75250
ino
Traffic Manager
Traffic Manager
Posts: 152
Joined: 09 Apr 2017 14:58

Re: The big picture and mentoring

Post by ino »

luxtram wrote:
This is exactly what I am trying to avoid to do. I do not want reverse engineer the the game architecture. It would take me unreasonable amount of time (that I do not have much to spend).

No it doesn't take unreasonable amount of time. Been there, done that. And knowing broad architecture doesn't help you find where you need to make the change anyway, because the game is huge.

Just read it, really. OpenTTD, especially vanilla, has a very good structure as much as C++ allow it to be.

Also, I don't even know where the game main loop is, and I have written patch as well as making my own modification fine without it.

Btw, _gui is, well, where GUI for the game is defined. _cmd is for command. Any changes make to game need to be done through command, usually defined in file end with _cmd, so that the multiplayer work. (This is a very common pattern in multi-player game/networked application)
luxtram wrote: Knowing the architecture would give tremendous help for figuring out the small parts.
Not really, no.

EDIT: And OpenTTD follow most common pattern use in game/network programming anyway. Unless you are totally new to this kind of program (which I assume you don't since you know what main loop is), then you shouldn't have any problem.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: The big picture and mentoring

Post by planetmaker »

In order to add what was said:

the main loop is - big surprise - in openttd.cpp. Yet looking at that loop never has helped my with anything really; it is so abstract that it usually is not helpful to look at. Maybe there's one exception: when I was trying to understand where the (OSX) screendriver hooked into the system... but even then it's far from that.

Generally: If you look for anything in particular: use a search tool to search the whole code base for whatever might be a good starting point. You look for NewGRF stuff? 'newgrf' will be in the filename. Fiddling with cargo amount? Grep for 'CARGO'. Etc etc.
User avatar
jfs
Tycoon
Tycoon
Posts: 1750
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: The big picture and mentoring

Post by jfs »

I jumped into the code about a year ago or a little less, and while there's still large chunks I've barely looked at, I've learned a bunch in that time.

What helped me learn was first and foremost, having a clear goal in mind for a change I wanted to make. To help me get that done I used the code exploration tools in the Visual Studio IDE, to find related code and definitions to what I was looking at.

In other worse, I started "inside-out", until I got to the point where I could look at the code "outside-in". There's still lots of black boxes for me.

Anyway, the _cmd files contain most of the core game logic. The _gui files contain most of the core interaction logic. The video drivers contain most of the OS-specific input and graphics output stuff, including controlling game loop timing.

OTTD is a large code base, focus on the parts of it that you find interesting, that's the best way to learn it in my experience.
User avatar
This is my name
Director
Director
Posts: 515
Joined: 17 Sep 2008 01:36
Location: SOMEWHERE IN LINGGI
Contact:

Re: The big picture and mentoring

Post by This is my name »

Peace be upon you.

From what is here, the game came to be from stitching one parcel after another?

Peace be upon you.
usecubes.com 3-D Pixel Design Software
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: The big picture and mentoring

Post by Lord Aro »

I just came across this: http://www.maizure.org/projects/decoded ... index.html

It's an extremely well written article that covers a surprising amount of the codebase and how it all fits together
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
User avatar
orudge
Administrator
Administrator
Posts: 25134
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Re: The big picture and mentoring

Post by orudge »

Very interesting, a fascinating and very well written article indeed.
User avatar
Simons Mith
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 14 Jan 2010 23:45

Re: The big picture and mentoring

Post by Simons Mith »

This is the first time in my life I have ever seen someone ask, 'Can I get a comprehensive overview of a game?' and then get something even remotely close to what they asked for.

Statistically I don't expect to see it happen twice.
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: The big picture and mentoring

Post by Hyronymus »

Simons Mith wrote:This is the first time in my life I have ever seen someone ask, 'Can I get a comprehensive overview of a game?' and then get something even remotely close to what they asked for.

Statistically I don't expect to see it happen twice.
Funny, I believe he asked for something else.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 15 guests