Page 1 of 1

The big picture and mentoring

Posted: 24 Nov 2018 00:29
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.

Re: The big picture and mentoring

Posted: 25 Nov 2018 06:44
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.

Re: The big picture and mentoring

Posted: 25 Nov 2018 13:13
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.

Re: The big picture and mentoring

Posted: 28 Nov 2018 09:28
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.

Re: The big picture and mentoring

Posted: 28 Nov 2018 14:08
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.

Re: The big picture and mentoring

Posted: 30 Nov 2018 21:56
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.

Re: The big picture and mentoring

Posted: 01 Jan 2019 10:31
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.

Re: The big picture and mentoring

Posted: 02 Jan 2019 10:38
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

Re: The big picture and mentoring

Posted: 07 Jan 2019 12:19
by orudge
Very interesting, a fascinating and very well written article indeed.

Re: The big picture and mentoring

Posted: 07 Jan 2019 18:56
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.

Re: The big picture and mentoring

Posted: 08 Jan 2019 07:25
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.