Skip to content

Commit 9b24fb4

Browse files
committed
#263: Removed time-varying driving DLS
1 parent d6d098c commit 9b24fb4

20 files changed

+130
-59
lines changed

TLM/TLM/Manager/Impl/OptionsManager.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public bool LoadData(byte[] data) {
130130
}
131131

132132
if (data.Length >= 28) {
133-
Options.setRealisticSpeeds(data[27] == (byte)1);
133+
Options.setIndividualDrivingStyle(data[27] == (byte)1);
134134
}
135135

136136
if (data.Length >= 29) {
@@ -189,6 +189,10 @@ public bool LoadData(byte[] data) {
189189
Options.setAllowFarTurnOnRed(data[40] == (byte)1);
190190
}
191191

192+
if (data.Length >= 42) {
193+
Options.setAllowFarTurnOnRed(data[41] == (byte)1);
194+
}
195+
192196
return true;
193197
}
194198

@@ -221,7 +225,7 @@ public byte[] SaveData(ref bool success) {
221225
(byte)(Options.junctionRestrictionsEnabled ? 1 : 0),
222226
(byte)(Options.prohibitPocketCars ? 1 : 0),
223227
(byte)(Options.preferOuterLane ? 1 : 0),
224-
(byte)(Options.realisticSpeeds ? 1 : 0),
228+
(byte)(Options.individualDrivingStyle ? 1 : 0),
225229
(byte)(Options.evacBussesMayIgnoreRules ? 1 : 0),
226230
(byte)(Options.instantEffects ? 1 : 0),
227231
(byte)(Options.parkingRestrictionsEnabled ? 1 : 0),

TLM/TLM/Manager/Impl/VehicleBehaviorManager.cs

+5-9
Original file line numberDiff line numberDiff line change
@@ -694,18 +694,11 @@ public uint GetStaticVehicleRand(ushort vehicleId) {
694694
}
695695

696696
public uint GetTimedVehicleRand(ushort vehicleId) {
697-
uint intv = VehicleState.MAX_TIMED_RAND / 2u;
698-
uint range = intv * (uint)(vehicleId % (100u / intv)); // is one of [0, 50]
699-
uint step = VehicleStateManager.Instance.VehicleStates[vehicleId].timedRand;
700-
if (step >= intv) {
701-
step = VehicleState.MAX_TIMED_RAND - step;
702-
}
703-
704-
return range + step;
697+
return (uint)(vehicleId % 2) * 50u + VehicleStateManager.Instance.VehicleStates[vehicleId].timedRand;
705698
}
706699

707700
public float ApplyRealisticSpeeds(float speed, ushort vehicleId, ref VehicleState state, VehicleInfo vehicleInfo) {
708-
if (Options.realisticSpeeds) {
701+
if (Options.individualDrivingStyle) {
709702
float vehicleRand = 0.01f * (float)GetTimedVehicleRand(vehicleId);
710703
if (vehicleInfo.m_isLargeVehicle) {
711704
speed *= 0.75f + vehicleRand * 0.25f; // a little variance, 0.75 .. 1
@@ -751,6 +744,9 @@ public int FindBestLane(ushort vehicleId, ref Vehicle vehicleData, ref VehicleSt
751744
Log._Debug($"VehicleBehaviorManager.FindBestLane({vehicleId}): currentLaneId={currentLaneId}, currentPathPos=[seg={currentPathPos.m_segment}, lane={currentPathPos.m_lane}, off={currentPathPos.m_offset}] next1PathPos=[seg={next1PathPos.m_segment}, lane={next1PathPos.m_lane}, off={next1PathPos.m_offset}] next2PathPos=[seg={next2PathPos.m_segment}, lane={next2PathPos.m_lane}, off={next2PathPos.m_offset}] next3PathPos=[seg={next3PathPos.m_segment}, lane={next3PathPos.m_lane}, off={next3PathPos.m_offset}] next4PathPos=[seg={next4PathPos.m_segment}, lane={next4PathPos.m_lane}, off={next4PathPos.m_offset}]");
752745
}
753746
#endif
747+
if (!vehicleState.dlsReady) {
748+
vehicleState.UpdateDynamicLaneSelectionParameters();
749+
}
754750

755751
if (vehicleState.lastAltLaneSelSegmentId == currentPathPos.m_segment) {
756752
#if DEBUG

TLM/TLM/Resources/lang.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration Reset global configuration
150150
General General
151151
Gameplay Gameplay
152152
Overlays Overlays
153-
Realistic_speeds Realistic speeds
153+
Individual_driving_styles Individual driving styles
154154
Evacuation_busses_may_ignore_traffic_rules Evacuation buses may ignore traffic rules
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter Evacuation buses may only be used to reach a shelter
156156
Vehicle_behavior Vehicle behavior

TLM/TLM/Resources/lang_de.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration Globale Konfiguration zurücksetzen
150150
General Allgemein
151151
Gameplay Gameplay
152152
Overlays Overlays
153-
Realistic_speeds Realistische Geschwindigkeiten
153+
Individual_driving_styles Individuelle Fahrstile
154154
Evacuation_busses_may_ignore_traffic_rules Evakuierungsbusse dürfen Verkehrsregeln missachten
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter Evakuierungsbusse dienen nur zum Erreichen einer Notunterkunft
156156
Vehicle_behavior Fahrzeugverhalten

TLM/TLM/Resources/lang_es.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration Restablecer configuración global
150150
General General
151151
Gameplay Jugabilidad
152152
Overlays Capas de información
153-
Realistic_speeds Velocidades realistas
153+
Individual_driving_styles Individual driving styles
154154
Evacuation_busses_may_ignore_traffic_rules Los buses de evacuación pueden ignorar reglas de tránsito
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter Los buses de evacuación sólo pueden usarse para llegar a un refugio
156156
Vehicle_behavior Comportamiento vehícular

TLM/TLM/Resources/lang_fr.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration Réinitialiser la config. globale
150150
General Général
151151
Gameplay Gameplay
152152
Overlays Interface
153-
Realistic_speeds Vitesses réalistes
153+
Individual_driving_styles Individual driving styles
154154
Evacuation_busses_may_ignore_traffic_rules Les bus d'évacuation peuvent ignorer les règles de trafic
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter Les bus d'évacuation ne peuvent être utilisés que pour atteindre un abri
156156
Vehicle_behavior Comportement des véhicules

TLM/TLM/Resources/lang_it.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration Resetta configurazione globale
150150
General Generale
151151
Gameplay Gameplay
152152
Overlays Overlays
153-
Realistic_speeds Velocità realistica dei veicoli
153+
Individual_driving_styles Individual driving styles
154154
Evacuation_busses_may_ignore_traffic_rules I bus di evacuazione possono ignorare le regole stradali
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter I bus di evacuazione possono essere usati solo per raggiungere un rifugio
156156
Vehicle_behavior Comportamente del veicolo

TLM/TLM/Resources/lang_ja.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration グローバル設定をリセット
150150
General 全般
151151
Gameplay ゲームプレイ
152152
Overlays オーバーレイ
153-
Realistic_speeds 現実的なスピード
153+
Individual_driving_styles Individual driving styles
154154
Evacuation_busses_may_ignore_traffic_rules 避難バスは交通規則を無視するであろう
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter 避難バスは避難所へのアクセスにのみ使用できます
156156
Vehicle_behavior 車両の挙動

TLM/TLM/Resources/lang_ko.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration 글로벌(global) 설정 초기화
150150
General 기본
151151
Gameplay 게임플레이
152152
Overlays 화면표시
153-
Realistic_speeds 현실적인 속도
153+
Individual_driving_styles Individual driving styles
154154
Evacuation_busses_may_ignore_traffic_rules 대피 버스는 교통규칙을 무시합니다
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter 대피 버스는 대피소 도착을 위한 용도로만 사용할 수 있습니다
156156
Vehicle_behavior 차량 제한

TLM/TLM/Resources/lang_nl.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Reset_global_configuration Reset algemene configuratie
151151
General Algemeen
152152
Gameplay Spelverloop
153153
Overlays Transparanten
154-
Realistic_speeds Realistische snelheden
154+
Individual_driving_styles Individual driving styles
155155
Evacuation_busses_may_ignore_traffic_rules Evacuatiebussen mogen verkeersregels overtreden
156156
Evacuation_busses_may_only_be_used_to_reach_a_shelter Evacuatiebussen mogen enkel gebruikt worden om schuilkelders te bereiken
157157
Vehicle_behavior Vortuiggedrag

TLM/TLM/Resources/lang_pl.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration Zresetuj ustawienia globalne
150150
General Ogólne
151151
Gameplay Rozgrywka
152152
Overlays Nakładki
153-
Realistic_speeds Realistyczne prędkości
153+
Individual_driving_styles Individual driving styles
154154
Evacuation_busses_may_ignore_traffic_rules Autobusy ewakuacyjne mogą ignorować przepisy
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter Autobusy ewakuacyjne mogą przewozić tylko do schroniena
156156
Vehicle_behavior Zachowanie pojazdu

TLM/TLM/Resources/lang_pt.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration Resetar configuração global
150150
General Geral
151151
Gameplay Gameplay
152152
Overlays Sobreposições
153-
Realistic_speeds Velocidades realistas
153+
Individual_driving_styles Individual driving styles
154154
Evacuation_busses_may_ignore_traffic_rules Os ônibus de evacuação podem ignorar as regras de trânsito
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter Os ônibus de evacuação só podem ser usados para alcançar um abrigo
156156
Vehicle_behavior Comportamento do veículo

TLM/TLM/Resources/lang_ru.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration Сбросить общую конфигурацию
150150
General Общее
151151
Gameplay Геймплей
152152
Overlays Оверлеи
153-
Realistic_speeds Реалистичные скорости
153+
Individual_driving_styles Individual driving styles
154154
Evacuation_busses_may_ignore_traffic_rules Автобусы эвакуации игнорируют правила движения
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter Эвакуационные автобусы, только чтобы добраться до аварийного убежища
156156
Vehicle_behavior Поведение транспорта

TLM/TLM/Resources/lang_template.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration
150150
General
151151
Gameplay
152152
Overlays
153-
Realistic_speeds
153+
Individual_driving_styles
154154
Evacuation_busses_may_ignore_traffic_rules
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter
156156
Vehicle_behavior

TLM/TLM/Resources/lang_zh-tw.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration 重置所有設定
150150
General 普通
151151
Gameplay 遊戲
152152
Overlays 重疊
153-
Realistic_speeds 現實速度
153+
Individual_driving_styles Individual driving styles
154154
Evacuation_busses_may_ignore_traffic_rules 緊急疏散公車可忽略交通規則
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter 緊急疏散公車僅可用於到達避難所
156156
Vehicle_behavior 車輛行為

TLM/TLM/Resources/lang_zh.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Reset_global_configuration 重置所有设定
150150
General 常规
151151
Gameplay 游戏
152152
Overlays 覆盖
153-
Realistic_speeds 真实车速
153+
Individual_driving_styles Individual driving styles
154154
Evacuation_busses_may_ignore_traffic_rules 应急疏散巴士可忽略交通规则
155155
Evacuation_busses_may_only_be_used_to_reach_a_shelter 应急疏散巴士仅可用于到达避难所
156156
Vehicle_behavior 车辆行为

TLM/TLM/State/ConfigData/DynamicLaneSelection.cs

+38-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public class DynamicLaneSelection {
4747

4848
// ---
4949

50+
/*
51+
* max. reserved space:
52+
* low = egoistic
53+
* high = altruistic
54+
*/
55+
5056
/// <summary>
5157
/// Minimum maximum allowed reserved space on previous vehicle lane (for regular drivers)
5258
/// </summary>
@@ -67,6 +73,12 @@ public class DynamicLaneSelection {
6773
/// </summary>
6874
public float MaxMaxRecklessReservedSpace = 50f;
6975

76+
/*
77+
* lane speed randomization interval:
78+
* low = altruistic (driver sees the true lane speed)
79+
* high = egoistic (driver imagines to be in the slowest queue, http://www.bbc.com/future/story/20130827-why-other-queues-move-faster)
80+
*/
81+
7082
/// <summary>
7183
/// Minimum lane speed randomization interval
7284
/// </summary>
@@ -77,6 +89,12 @@ public class DynamicLaneSelection {
7789
/// </summary>
7890
public float MaxLaneSpeedRandInterval = 25f;
7991

92+
/*
93+
* max. considered lane changes:
94+
* low = altruistic
95+
* high = egoistic
96+
*/
97+
8098
/// <summary>
8199
/// Maximum number of considered lane changes
82100
/// </summary>
@@ -87,16 +105,28 @@ public class DynamicLaneSelection {
87105
/// </summary>
88106
public int MaxMaxOptLaneChanges = 3;
89107

108+
/*
109+
* max. allowed speed difference for unsafe lane changes
110+
* low = altruistic
111+
* high = egoistic
112+
*/
113+
90114
/// <summary>
91-
/// Minimum maximum allowed speed difference for safe lane changes (in game units)
115+
/// Minimum maximum allowed speed difference for unsafe lane changes (in game units)
92116
/// </summary>
93117
public float MinMaxUnsafeSpeedDiff = 0.1f;
94118

95119
/// <summary>
96-
/// Maximum maximum allowed speed difference for safe lane changes (in game units)
120+
/// Maximum maximum allowed speed difference for unsafe lane changes (in game units)
97121
/// </summary>
98122
public float MaxMaxUnsafeSpeedDiff = 1f;
99123

124+
/*
125+
* min. required speed improvement for safe lane changes
126+
* low = egoistic
127+
* high = altruistic
128+
*/
129+
100130
/// <summary>
101131
/// Minimum minimum required speed improvement for safe lane changes (in km/h)
102132
/// </summary>
@@ -107,6 +137,12 @@ public class DynamicLaneSelection {
107137
/// </summary>
108138
public float MaxMinSafeSpeedImprovement = 30f;
109139

140+
/*
141+
* min. required traffic flow improvement for safe lane changes
142+
* low = egoistic
143+
* high = altruistic
144+
*/
145+
110146
/// <summary>
111147
/// Minimum minimum required traffic flow improvement for safe lane changes (in %)
112148
/// </summary>

TLM/TLM/State/ConfigData/Gameplay.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
namespace TrafficManager.State.ConfigData {
77
public class Gameplay {
88
/// <summary>
9-
/// Modulo value for vehicle behavior randomization
9+
/// Modulo value for time-varying vehicle behavior randomization
1010
/// </summary>
11-
public uint VehicleStepRand = 20;
11+
public uint VehicleTimedRandModulo = 10;
1212
}
1313
}

TLM/TLM/State/Options.cs

+21-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class Options : MonoBehaviour {
3131
private static UICheckBox showCompatibilityCheckErrorToggle = null;
3232
private static UICheckBox scanForKnownIncompatibleModsToggle = null;
3333
private static UICheckBox ignoreDisabledModsToggle = null;
34-
private static UICheckBox realisticSpeedsToggle = null;
34+
private static UICheckBox individualDrivingStyleToggle = null;
3535
private static UIDropDown recklessDriversDropdown = null;
3636
private static UICheckBox relaxedBussesToggle = null;
3737
private static UICheckBox allRelaxedToggle = null;
@@ -95,7 +95,7 @@ public class Options : MonoBehaviour {
9595
public static bool instantEffects = true;
9696
public static int simAccuracy = 0;
9797
//public static int laneChangingRandomization = 2;
98-
public static bool realisticSpeeds = true;
98+
public static bool individualDrivingStyle = true;
9999
public static int recklessDrivers = 3;
100100
public static bool relaxedBusses = false;
101101
public static bool allRelaxed = false;
@@ -259,7 +259,8 @@ public static void makeSettings(UIHelperBase helper) {
259259

260260
recklessDriversDropdown = vehBehaviorGroup.AddDropdown(Translation.GetString("Reckless_driving") + ":", new string[] { Translation.GetString("Path_Of_Evil_(10_%)"), Translation.GetString("Rush_Hour_(5_%)"), Translation.GetString("Minor_Complaints_(2_%)"), Translation.GetString("Holy_City_(0_%)") }, recklessDrivers, onRecklessDriversChanged) as UIDropDown;
261261
recklessDriversDropdown.width = 300;
262-
realisticSpeedsToggle = vehBehaviorGroup.AddCheckbox(Translation.GetString("Realistic_speeds"), realisticSpeeds, onRealisticSpeedsChanged) as UICheckBox;
262+
individualDrivingStyleToggle = vehBehaviorGroup.AddCheckbox(Translation.GetString("Individual_driving_styles"), individualDrivingStyle, onIndividualDrivingStyleChanged) as UICheckBox;
263+
263264
if (SteamHelper.IsDLCOwned(SteamHelper.DLC.SnowFallDLC)) {
264265
strongerRoadConditionEffectsToggle = vehBehaviorGroup.AddCheckbox(Translation.GetString("Road_condition_has_a_bigger_impact_on_vehicle_speed"), strongerRoadConditionEffects, onStrongerRoadConditionEffectsChanged) as UICheckBox;
265266
}
@@ -1005,12 +1006,12 @@ private static void onRealisticPublicTransportChanged(bool newValue) {
10051006
realisticPublicTransport = newValue;
10061007
}
10071008

1008-
private static void onRealisticSpeedsChanged(bool value) {
1009+
private static void onIndividualDrivingStyleChanged(bool value) {
10091010
if (!checkGameLoaded())
10101011
return;
10111012

1012-
Log._Debug($"realisticSpeeds changed to {value}");
1013-
realisticSpeeds = value;
1013+
Log._Debug($"individualDrivingStyle changed to {value}");
1014+
setIndividualDrivingStyle(value);
10141015
}
10151016

10161017
private static void onDisableDespawningChanged(bool value) {
@@ -1277,10 +1278,12 @@ public static void setRealisticPublicTransport(bool newValue) {
12771278
realisticPublicTransportToggle.isChecked = newValue;
12781279
}
12791280

1280-
public static void setRealisticSpeeds(bool newValue) {
1281-
realisticSpeeds = newValue;
1282-
if (realisticSpeedsToggle != null)
1283-
realisticSpeedsToggle.isChecked = newValue;
1281+
public static void setIndividualDrivingStyle(bool newValue) {
1282+
individualDrivingStyle = newValue;
1283+
1284+
if (individualDrivingStyleToggle != null) {
1285+
individualDrivingStyleToggle.isChecked = newValue;
1286+
}
12841287
}
12851288

12861289
public static void setDisableDespawning(bool value) {
@@ -1556,5 +1559,13 @@ internal static int getRecklessDriverModulo() {
15561559
}
15571560
return 10000;
15581561
}
1562+
1563+
/// <summary>
1564+
/// Determines whether Dynamic Lane Selection (DLS) is enabled.
1565+
/// </summary>
1566+
/// <returns></returns>
1567+
public static bool IsDynamicLaneSelectionActive() {
1568+
return advancedAI && altLaneSelectionRatio > 0;
1569+
}
15591570
}
15601571
}

0 commit comments

Comments
 (0)