Import day length patch
Minor whitespace fixes. http://www.tt-forums.net/viewtopic.php?p=1148227#p1148227
This commit is contained in:

committed by
Jonathan G Rennison

parent
be00f631da
commit
d86a56cbef
@@ -28,6 +28,7 @@ Month _cur_month; ///< Current month (0..11)
|
|||||||
Date _date; ///< Current date in days (day counter)
|
Date _date; ///< Current date in days (day counter)
|
||||||
DateFract _date_fract; ///< Fractional part of the day.
|
DateFract _date_fract; ///< Fractional part of the day.
|
||||||
uint16 _tick_counter; ///< Ever incrementing (and sometimes wrapping) tick counter for setting off various events
|
uint16 _tick_counter; ///< Ever incrementing (and sometimes wrapping) tick counter for setting off various events
|
||||||
|
uint8 _tick_skip_counter; ///< Counter for ticks, when only vehicles are moving and nothing else happens
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the date.
|
* Set the date.
|
||||||
|
@@ -18,7 +18,8 @@ extern Year _cur_year;
|
|||||||
extern Month _cur_month;
|
extern Month _cur_month;
|
||||||
extern Date _date;
|
extern Date _date;
|
||||||
extern DateFract _date_fract;
|
extern DateFract _date_fract;
|
||||||
extern uint16 _tick_counter;
|
extern uint16 _tick_counter;
|
||||||
|
extern uint8 _tick_skip_counter;
|
||||||
|
|
||||||
void SetDate(Date date, DateFract fract);
|
void SetDate(Date date, DateFract fract);
|
||||||
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
|
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
|
||||||
|
@@ -1527,6 +1527,8 @@ STR_CONFIG_SETTING_ALLOW_SHARES :Allow buying sh
|
|||||||
STR_CONFIG_SETTING_ALLOW_SHARES_HELPTEXT :When enabled, allow buying and selling of company shares. Shares will only be available for companies reaching a certain age
|
STR_CONFIG_SETTING_ALLOW_SHARES_HELPTEXT :When enabled, allow buying and selling of company shares. Shares will only be available for companies reaching a certain age
|
||||||
STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE :Percentage of leg profit to pay in feeder systems: {STRING2}
|
STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE :Percentage of leg profit to pay in feeder systems: {STRING2}
|
||||||
STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE_HELPTEXT :Percentage of income given to the intermediate legs in feeder systems, giving more control over the income
|
STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE_HELPTEXT :Percentage of income given to the intermediate legs in feeder systems, giving more control over the income
|
||||||
|
STR_CONFIG_SETTING_DAY_LENGTH_FACTOR :Day length factor: {STRING2}
|
||||||
|
STR_CONFIG_SETTING_DAY_LENGTH_FACTOR_HELPTEXT :Game pace is slowed by this factor
|
||||||
STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY :When dragging, place signals every: {STRING2}
|
STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY :When dragging, place signals every: {STRING2}
|
||||||
STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY_HELPTEXT :Set the distance at which signals will be built on a track up to the next obstacle (signal, junction), if signals are dragged
|
STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY_HELPTEXT :Set the distance at which signals will be built on a track up to the next obstacle (signal, junction), if signals are dragged
|
||||||
STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY_VALUE :{COMMA} tile{P 0 "" s}
|
STR_CONFIG_SETTING_DRAG_SIGNALS_DENSITY_VALUE :{COMMA} tile{P 0 "" s}
|
||||||
|
@@ -62,6 +62,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
|
|||||||
_pause_mode = PM_UNPAUSED;
|
_pause_mode = PM_UNPAUSED;
|
||||||
_fast_forward = 0;
|
_fast_forward = 0;
|
||||||
_tick_counter = 0;
|
_tick_counter = 0;
|
||||||
|
_tick_skip_counter = 0;
|
||||||
_cur_tileloop_tile = 1;
|
_cur_tileloop_tile = 1;
|
||||||
_thd.redsq = INVALID_TILE;
|
_thd.redsq = INVALID_TILE;
|
||||||
if (reset_settings) MakeNewgameSettingsLive();
|
if (reset_settings) MakeNewgameSettingsLive();
|
||||||
|
@@ -1377,11 +1377,17 @@ void StateGameLoop()
|
|||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
|
|
||||||
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP);
|
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP);
|
||||||
AnimateAnimatedTiles();
|
_tick_skip_counter++;
|
||||||
IncreaseDate();
|
if (_tick_skip_counter < _settings_game.economy.day_length_factor) {
|
||||||
RunTileLoop();
|
CallVehicleTicks();
|
||||||
CallVehicleTicks();
|
} else {
|
||||||
CallLandscapeTick();
|
_tick_skip_counter = 0;
|
||||||
|
AnimateAnimatedTiles();
|
||||||
|
IncreaseDate();
|
||||||
|
RunTileLoop();
|
||||||
|
CallVehicleTicks();
|
||||||
|
CallLandscapeTick();
|
||||||
|
}
|
||||||
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP);
|
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP);
|
||||||
|
|
||||||
#ifndef DEBUG_DUMP_COMMANDS
|
#ifndef DEBUG_DUMP_COMMANDS
|
||||||
|
@@ -75,6 +75,7 @@ static const SaveLoadGlobVarList _date_desc[] = {
|
|||||||
SLEG_CONDVAR(_date, SLE_INT32, 31, SL_MAX_VERSION),
|
SLEG_CONDVAR(_date, SLE_INT32, 31, SL_MAX_VERSION),
|
||||||
SLEG_VAR(_date_fract, SLE_UINT16),
|
SLEG_VAR(_date_fract, SLE_UINT16),
|
||||||
SLEG_VAR(_tick_counter, SLE_UINT16),
|
SLEG_VAR(_tick_counter, SLE_UINT16),
|
||||||
|
SLEG_CONDVAR(_tick_skip_counter, SLE_UINT8, 200, SL_MAX_VERSION),
|
||||||
SLE_CONDNULL(2, 0, 156), // _vehicle_id_ctr_day
|
SLE_CONDNULL(2, 0, 156), // _vehicle_id_ctr_day
|
||||||
SLEG_CONDVAR(_age_cargo_skip_counter, SLE_UINT8, 0, 161),
|
SLEG_CONDVAR(_age_cargo_skip_counter, SLE_UINT8, 0, 161),
|
||||||
SLE_CONDNULL(1, 0, 45),
|
SLE_CONDNULL(1, 0, 45),
|
||||||
@@ -100,6 +101,7 @@ static const SaveLoadGlobVarList _date_check_desc[] = {
|
|||||||
SLEG_CONDVAR(_load_check_data.current_date, SLE_INT32, 31, SL_MAX_VERSION),
|
SLEG_CONDVAR(_load_check_data.current_date, SLE_INT32, 31, SL_MAX_VERSION),
|
||||||
SLE_NULL(2), // _date_fract
|
SLE_NULL(2), // _date_fract
|
||||||
SLE_NULL(2), // _tick_counter
|
SLE_NULL(2), // _tick_counter
|
||||||
|
SLEG_CONDVAR(_tick_skip_counter, SLE_UINT8, 200, SL_MAX_VERSION),
|
||||||
SLE_CONDNULL(2, 0, 156), // _vehicle_id_ctr_day
|
SLE_CONDNULL(2, 0, 156), // _vehicle_id_ctr_day
|
||||||
SLE_CONDNULL(1, 0, 161), // _age_cargo_skip_counter
|
SLE_CONDNULL(1, 0, 161), // _age_cargo_skip_counter
|
||||||
SLE_CONDNULL(1, 0, 45),
|
SLE_CONDNULL(1, 0, 45),
|
||||||
|
@@ -263,7 +263,7 @@
|
|||||||
* 193 26802
|
* 193 26802
|
||||||
* 194 26881 1.5.x
|
* 194 26881 1.5.x
|
||||||
*/
|
*/
|
||||||
extern const uint16 SAVEGAME_VERSION = 194; ///< Current savegame version of OpenTTD.
|
extern const uint16 SAVEGAME_VERSION = 200; ///< Current savegame version of OpenTTD.
|
||||||
|
|
||||||
SavegameType _savegame_type; ///< type of savegame we are loading
|
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||||
|
|
||||||
|
@@ -1591,6 +1591,7 @@ static SettingsContainer &GetSettingsTree()
|
|||||||
SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));
|
SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));
|
||||||
{
|
{
|
||||||
accounting->Add(new SettingEntry("economy.inflation"));
|
accounting->Add(new SettingEntry("economy.inflation"));
|
||||||
|
accounting->Add(new SettingEntry("economy.day_length_factor"));
|
||||||
accounting->Add(new SettingEntry("difficulty.initial_interest"));
|
accounting->Add(new SettingEntry("difficulty.initial_interest"));
|
||||||
accounting->Add(new SettingEntry("difficulty.max_loan"));
|
accounting->Add(new SettingEntry("difficulty.max_loan"));
|
||||||
accounting->Add(new SettingEntry("difficulty.subsidy_multiplier"));
|
accounting->Add(new SettingEntry("difficulty.subsidy_multiplier"));
|
||||||
|
@@ -488,6 +488,7 @@ struct EconomySettings {
|
|||||||
uint16 town_noise_population[3]; ///< population to base decision on noise evaluation (@see town_council_tolerance)
|
uint16 town_noise_population[3]; ///< population to base decision on noise evaluation (@see town_council_tolerance)
|
||||||
bool allow_town_level_crossings; ///< towns are allowed to build level crossings
|
bool allow_town_level_crossings; ///< towns are allowed to build level crossings
|
||||||
bool infrastructure_maintenance; ///< enable monthly maintenance fee for owner infrastructure
|
bool infrastructure_maintenance; ///< enable monthly maintenance fee for owner infrastructure
|
||||||
|
uint8 day_length_factor; ///< factor which the length of day is multiplied
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LinkGraphSettings {
|
struct LinkGraphSettings {
|
||||||
|
@@ -1262,6 +1262,19 @@ str = STR_CONFIG_SETTING_INFLATION
|
|||||||
strhelp = STR_CONFIG_SETTING_INFLATION_HELPTEXT
|
strhelp = STR_CONFIG_SETTING_INFLATION_HELPTEXT
|
||||||
cat = SC_BASIC
|
cat = SC_BASIC
|
||||||
|
|
||||||
|
[SDT_VAR]
|
||||||
|
base = GameSettings
|
||||||
|
var = economy.day_length_factor
|
||||||
|
type = SLE_UINT8
|
||||||
|
from = 200
|
||||||
|
def = 1
|
||||||
|
min = 1
|
||||||
|
max = 125
|
||||||
|
str = STR_CONFIG_SETTING_DAY_LENGTH_FACTOR
|
||||||
|
strhelp = STR_CONFIG_SETTING_DAY_LENGTH_FACTOR_HELPTEXT
|
||||||
|
strval = STR_JUST_COMMA
|
||||||
|
cat = SC_BASIC
|
||||||
|
|
||||||
[SDT_VAR]
|
[SDT_VAR]
|
||||||
base = GameSettings
|
base = GameSettings
|
||||||
var = construction.raw_industry_construction
|
var = construction.raw_industry_construction
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include "vehicle_base.h"
|
#include "vehicle_base.h"
|
||||||
#include "cmd_helper.h"
|
#include "cmd_helper.h"
|
||||||
#include "core/sort_func.hpp"
|
#include "core/sort_func.hpp"
|
||||||
|
#include "settings_type.h"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
@@ -384,7 +385,7 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
|
|||||||
just_started = !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
|
just_started = !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
|
||||||
|
|
||||||
if (v->timetable_start != 0) {
|
if (v->timetable_start != 0) {
|
||||||
v->lateness_counter = (_date - v->timetable_start) * DAY_TICKS + _date_fract;
|
v->lateness_counter = (_date - v->timetable_start) * DAY_TICKS * _settings_game.economy.day_length_factor + _date_fract + _tick_skip_counter;
|
||||||
v->timetable_start = 0;
|
v->timetable_start = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -878,7 +878,7 @@ void CallVehicleTicks()
|
|||||||
{
|
{
|
||||||
_vehicles_to_autoreplace.Clear();
|
_vehicles_to_autoreplace.Clear();
|
||||||
|
|
||||||
RunVehicleDayProc();
|
if (_tick_skip_counter == 0) RunVehicleDayProc();
|
||||||
|
|
||||||
Station *st;
|
Station *st;
|
||||||
FOR_ALL_STATIONS(st) LoadUnloadStation(st);
|
FOR_ALL_STATIONS(st) LoadUnloadStation(st);
|
||||||
|
Reference in New Issue
Block a user