Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Thu Dec 13, 2018 9:56 am

All times are UTC




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sat Nov 24, 2018 12:29 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Tue May 10, 2016 7:09 pm
Posts: 330
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


Top
   
PostPosted: Sun Nov 25, 2018 6:44 am 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 7228
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.

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
PostPosted: Sun Nov 25, 2018 1:13 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Tue May 10, 2016 7:09 pm
Posts: 330
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


Top
   
PostPosted: Wed Nov 28, 2018 9:28 am 
Offline
Engineer
Engineer

Joined: Sun Apr 09, 2017 2:58 pm
Posts: 96
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.


Top
   
PostPosted: Wed Nov 28, 2018 2:08 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9062
Location: Sol d
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.

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Fri Nov 30, 2018 9:56 pm 
Offline
Route Supervisor
Route Supervisor
User avatar

Joined: Wed Jan 08, 2003 11:09 pm
Posts: 386
Location: Denmark
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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.