FS#3157 - Day length patch

Attached to Project: OpenTTD
Opened by Pavel Grim (pavel1269) - Saturday, 29 August 2009, 15:24 GMT
Type Patch
Category Core
Status New
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No


Patch to adjust day length. Not first, I know, but I think (hope) that finaly completed.

For more info:
This task depends upon

Comment by Alberth (Alberth) - Saturday, 29 August 2009, 21:24 GMT
Just a few code style comments and other things I noticed, I have no idea about how good or bad this patch is in other aspects.
I just pick random code fragments I encounter, most comments apply at many places in the code.

+ if( _settings_game.economy.day_length_balance_type == DBT_ALL_COSTS )
+ res.AffectCost( _settings_game.economy.day_length_balance_factor );
Coding style errors.
no space after if
an additional space inside the outer parentheses
statement after the if is not allowed in this way. either at the same line, or use curly brackets

+ if( (((_date_fract % DAY_TICKS) == 0) && ( !(_settings_game.economy.slow_down_industry_changes) )) ||
+ ( _date_fract == 0 ) )
+ {
+ IndustryDailyLoop();
+ }
Coding style errors.
no space after if
an additional space inside the outer parentheses
unneeded parentheses all over the place
open curly bracket at same line as the if, not below it

+* Returns a number of days in current month.
+static Day DaysInCurrentMonth()
Also document the returned value with @return

+* Return a day and tick, where new month on day length 1 would start.
+static void NewMonthAt( Day cur_day, DayTick *dt )
"return" ?
formal parameters must also be documented with @param

+#define DAYS_IN_YEAR 365 ///< days per year
+#define DAYS_IN_LEAP_YEAR 366 ///< sometimes, you need one day more...
don't change enums back to #define

nearby are CONFIG_SETTINGS which seems a better name than CONFIG_PATCHES to me

+ UpdateGraphPerformance();
in a list if InitializeXXXX calls. looks fishy. perhaps rename it?

+static bool UpdateAllCosts(int32 p1)
static functions must also be documented
Comment by Pavel Grim (pavel1269) - Sunday, 30 August 2009, 11:11 GMT
Updated coding style.