News:

Want to praise Simutrans?
Your feedback is important for us ;D.

City growth code

Started by jamespetts, December 15, 2013, 09:55:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jamespetts

I need to embark on some work in fixing and probably redesigning city growth code in Experimental's devel-new branch to prepare for the next major release. However, city growth is not an area of the code into which I have previously delved. Would any of the Standard developers be so kind to give me a brief overview of how the code is intended to work, and the main methods/functions (which exactly is the correct term for C++ in any event?) that handle city growth? I should be exceedingly grateful.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

prissi

THe calculations all happens in void stadt_t::step(long delta_t)
There are two functions then calc_growth() and step_grow_city(). There the actual magic happens. But I am not sure if experimetnal is still using the same.

jamespetts

Thank you - that is helpful. Experimental has not made major changes to these yet. In general terms, how do calc_growth() and step_grow_city() work?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ters

Quote from: jamespetts on December 15, 2013, 09:55:15 PM
methods/functions (which exactly is the correct term for C++ in any event?)

Standalone functions (like main()) are a functions. Functions that are part of a class are member functions.

jamespetts

Intriguing - I had originally thought that all object oriented languages used the term "method" for what are described here as "member functions". It is confusing that C++ is not a functional language yet has "functions"...
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

wlindley

Even Microsoft BASIC in the early 1980s had functions:  10 DEF FNFOO(X)=X^2

Ters

Quote from: jamespetts on December 16, 2013, 10:01:46 AM
It is confusing that C++ is not a functional language yet has "functions"...

Well, you can do some simple functional programming with C++.

jamespetts

Quote from: Ters on December 16, 2013, 06:10:56 PM
Well, you can do some simple functional programming with C++.

Yes, I suppose that that is also confusing, as is much about C++...
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

kierongreen

Not really - C++ like many languages gives you a variety of tools to write your code in. As was pointed out many BASIC variants have functions as well as procedures.