mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-11 16:54:42 +00:00
Change: Use seconds for Linkgraph update settings (#10610)
This commit is contained in:
parent
0e915c830c
commit
646a7e625b
@ -30,6 +30,8 @@ static const int DAYS_IN_YEAR = 365; ///< days per year
|
||||
static const int DAYS_IN_LEAP_YEAR = 366; ///< sometimes, you need one day more...
|
||||
static const int MONTHS_IN_YEAR = 12; ///< months per year
|
||||
|
||||
static const int SECONDS_PER_DAY = 2; ///< approximate seconds per day, not for precise calculations
|
||||
|
||||
static const int STATION_RATING_TICKS = 185; ///< cycle duration for updating station rating
|
||||
static const int STATION_ACCEPTANCE_TICKS = 250; ///< cycle duration for updating station acceptance
|
||||
static const int STATION_LINKGRAPH_TICKS = 504; ///< cycle duration for cleaning dead links
|
||||
|
@ -1926,10 +1926,10 @@ STR_CONFIG_SETTING_LARGER_TOWNS_DISABLED :None
|
||||
STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER :Initial city size multiplier: {STRING2}
|
||||
STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER_HELPTEXT :Average size of cities relative to normal towns at start of the game
|
||||
|
||||
STR_CONFIG_SETTING_LINKGRAPH_INTERVAL :Update distribution graph every {STRING2}{NBSP}day{P 0:2 "" s}
|
||||
STR_CONFIG_SETTING_LINKGRAPH_INTERVAL_HELPTEXT :Time between subsequent recalculations of the link graph. Each recalculation calculates the plans for one component of the graph. That means that a value X for this setting does not mean the whole graph will be updated every X days. Only some component will. The shorter you set it the more CPU time will be necessary to calculate it. The longer you set it the longer it will take until the cargo distribution starts on new routes.
|
||||
STR_CONFIG_SETTING_LINKGRAPH_TIME :Take {STRING2}{NBSP}day{P 0:2 "" s} for recalculation of distribution graph
|
||||
STR_CONFIG_SETTING_LINKGRAPH_TIME_HELPTEXT :Time taken for each recalculation of a link graph component. When a recalculation is started, a thread is spawned which is allowed to run for this number of days. The shorter you set this the more likely it is that the thread is not finished when it's supposed to. Then the game stops until it is ("lag"). The longer you set it the longer it takes for the distribution to be updated when routes change.
|
||||
STR_CONFIG_SETTING_LINKGRAPH_RECALC_INTERVAL :Update distribution graph every {STRING2}{NBSP}second{P 0:2 "" s}
|
||||
STR_CONFIG_SETTING_LINKGRAPH_RECALC_INTERVAL_HELPTEXT :Time between subsequent recalculations of the link graph. Each recalculation calculates the plans for one component of the graph. That means that a value X for this setting does not mean the whole graph will be updated every X seconds. Only some component will. The shorter you set it the more CPU time will be necessary to calculate it. The longer you set it the longer it will take until the cargo distribution starts on new routes.
|
||||
STR_CONFIG_SETTING_LINKGRAPH_RECALC_TIME :Take {STRING2}{NBSP}second{P 0:2 "" s} for recalculation of distribution graph
|
||||
STR_CONFIG_SETTING_LINKGRAPH_RECALC_TIME_HELPTEXT :Time taken for each recalculation of a link graph component. When a recalculation is started, a thread is spawned which is allowed to run for this number of seconds. The shorter you set this the more likely it is that the thread is not finished when it's supposed to. Then the game stops until it is ("lag"). The longer you set it the longer it takes for the distribution to be updated when routes change.
|
||||
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_PAX :Distribution mode for passengers: {STRING2}
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_PAX_HELPTEXT :"Symmetric" means that roughly the same number of passengers will go from a station A to a station B as from B to A. "Asymmetric" means that arbitrary numbers of passengers can go in either direction. "Manual" means that no automatic distribution will take place for passengers.
|
||||
|
@ -37,7 +37,7 @@ LinkGraphJob::LinkGraphJob(const LinkGraph &orig) :
|
||||
* This is on purpose. */
|
||||
link_graph(orig),
|
||||
settings(_settings_game.linkgraph),
|
||||
join_date(_date + _settings_game.linkgraph.recalc_time),
|
||||
join_date(_date + (_settings_game.linkgraph.recalc_time / SECONDS_PER_DAY)),
|
||||
job_completed(false),
|
||||
job_aborted(false)
|
||||
{
|
||||
|
@ -178,7 +178,7 @@ void StateGameLoop_LinkGraphPauseControl()
|
||||
}
|
||||
} else if (_pause_mode == PM_UNPAUSED &&
|
||||
_date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK - 2 &&
|
||||
_date % _settings_game.linkgraph.recalc_interval == _settings_game.linkgraph.recalc_interval / 2 &&
|
||||
_date % (_settings_game.linkgraph.recalc_interval / SECONDS_PER_DAY) == (_settings_game.linkgraph.recalc_interval / SECONDS_PER_DAY) / 2 &&
|
||||
LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) {
|
||||
/* Perform check two _date_fract ticks before we would join, to make
|
||||
* sure it also works in multiplayer. */
|
||||
@ -205,10 +205,10 @@ void AfterLoad_LinkGraphPauseControl()
|
||||
void OnTick_LinkGraph()
|
||||
{
|
||||
if (_date_fract != LinkGraphSchedule::SPAWN_JOIN_TICK) return;
|
||||
Date offset = _date % _settings_game.linkgraph.recalc_interval;
|
||||
Date offset = _date % (_settings_game.linkgraph.recalc_interval / SECONDS_PER_DAY);
|
||||
if (offset == 0) {
|
||||
LinkGraphSchedule::instance.SpawnNext();
|
||||
} else if (offset == _settings_game.linkgraph.recalc_interval / 2) {
|
||||
} else if (offset == (_settings_game.linkgraph.recalc_interval / SECONDS_PER_DAY) / 2) {
|
||||
if (!_networking || _network_server) {
|
||||
PerformanceMeasurer::SetInactive(PFE_GL_LINKGRAPH);
|
||||
LinkGraphSchedule::instance.JoinNext();
|
||||
|
@ -799,6 +799,12 @@ bool AfterLoadGame()
|
||||
_settings_game.game_creation.ending_year = DEF_END_YEAR;
|
||||
}
|
||||
|
||||
/* Convert linkgraph update settings from days to seconds. */
|
||||
if (IsSavegameVersionBefore(SLV_LINKGRAPH_SECONDS)) {
|
||||
_settings_game.linkgraph.recalc_interval *= SECONDS_PER_DAY;
|
||||
_settings_game.linkgraph.recalc_time *= SECONDS_PER_DAY;
|
||||
}
|
||||
|
||||
/* Load the sprites */
|
||||
GfxLoadSprites();
|
||||
LoadStringWidthTable();
|
||||
|
@ -350,6 +350,7 @@ enum SaveLoadVersion : uint16 {
|
||||
SLV_VELOCITY_NAUTICAL, ///< 305 PR#10594 Separation of land and nautical velocity (knots!)
|
||||
SLV_CONSISTENT_PARTIAL_Z, ///< 306 PR#10570 Conversion from an inconsistent partial Z calculation for slopes, to one that is (more) consistent.
|
||||
SLV_MORE_CARGO_AGE, ///< 307 PR#10596 Track cargo age for a longer period.
|
||||
SLV_LINKGRAPH_SECONDS, ///< 308 PR#10610 Store linkgraph update intervals in seconds instead of days.
|
||||
|
||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||
};
|
||||
|
@ -157,6 +157,7 @@ enum IniFileVersion : uint32 {
|
||||
IFV_0, ///< 0 All versions prior to introduction.
|
||||
IFV_PRIVATE_SECRETS, ///< 1 PR#9298 Moving of settings from openttd.cfg to private.cfg / secrets.cfg.
|
||||
IFV_GAME_TYPE, ///< 2 PR#9515 Convert server_advertise to server_game_type.
|
||||
IFV_LINKGRAPH_SECONDS, ///< 3 PR#10610 Store linkgraph update intervals in seconds instead of days.
|
||||
|
||||
IFV_MAX_VERSION, ///< Highest possible ini-file version.
|
||||
};
|
||||
@ -1236,6 +1237,11 @@ void LoadFromConfig(bool startup)
|
||||
}
|
||||
}
|
||||
|
||||
if (generic_version < IFV_LINKGRAPH_SECONDS) {
|
||||
_settings_newgame.linkgraph.recalc_interval *= SECONDS_PER_DAY;
|
||||
_settings_newgame.linkgraph.recalc_time *= SECONDS_PER_DAY;
|
||||
}
|
||||
|
||||
_grfconfig_newgame = GRFLoadConfig(generic_ini, "newgrf", false);
|
||||
_grfconfig_static = GRFLoadConfig(generic_ini, "newgrf-static", true);
|
||||
AILoadConfig(generic_ini, "ai_players");
|
||||
|
@ -37,26 +37,26 @@ startup = false
|
||||
var = linkgraph.recalc_interval
|
||||
type = SLE_UINT16
|
||||
from = SLV_183
|
||||
def = 4
|
||||
min = 2
|
||||
max = 32
|
||||
interval = 2
|
||||
str = STR_CONFIG_SETTING_LINKGRAPH_INTERVAL
|
||||
def = 8
|
||||
min = 4
|
||||
max = 90
|
||||
interval = 1
|
||||
str = STR_CONFIG_SETTING_LINKGRAPH_RECALC_INTERVAL
|
||||
strval = STR_JUST_COMMA
|
||||
strhelp = STR_CONFIG_SETTING_LINKGRAPH_INTERVAL_HELPTEXT
|
||||
strhelp = STR_CONFIG_SETTING_LINKGRAPH_RECALC_INTERVAL_HELPTEXT
|
||||
extra = offsetof(LinkGraphSettings, recalc_interval)
|
||||
|
||||
[SDT_VAR]
|
||||
var = linkgraph.recalc_time
|
||||
type = SLE_UINT16
|
||||
from = SLV_183
|
||||
def = 16
|
||||
def = 32
|
||||
min = 1
|
||||
max = 4096
|
||||
max = 9000
|
||||
interval = 1
|
||||
str = STR_CONFIG_SETTING_LINKGRAPH_TIME
|
||||
str = STR_CONFIG_SETTING_LINKGRAPH_RECALC_TIME
|
||||
strval = STR_JUST_COMMA
|
||||
strhelp = STR_CONFIG_SETTING_LINKGRAPH_TIME_HELPTEXT
|
||||
strhelp = STR_CONFIG_SETTING_LINKGRAPH_RECALC_TIME_HELPTEXT
|
||||
extra = offsetof(LinkGraphSettings, recalc_time)
|
||||
|
||||
[SDT_VAR]
|
||||
|
Loading…
Reference in New Issue
Block a user