Skip to content

Commit a93c7a5

Browse files
authored
Merge pull request #493 from memo33/redundant-adjacencies-removal
[DLL] Remove redundant RUL2 adjacencies For integration with the DLL-based RUL2 engine, this PR aims to remove a lot of RUL2 code made redundant by the adjacency handling of the DLL. ### DLL-based adjacencies in a nutshell Whenever you have two adjacent tiles `A | B`, the engine looks for an _orthogonal_ surrogate tile `S` and matching RUL2 rules `A | S ⇒ A' | S'` as well as `S' | B ⇒ S" | B'` that make an override carry over from `A` to `S` to `B`. It then applies the result to the original tiles `A | B` directly, effectively applying a "virtual" rule `A | B ⇒ A' | B'`. This means you only need to write RUL2 code that connects to pure orthogonals (in and out), but no adjacencies. Diagonals work similarly, except they use _two_ _diagonal_ surrogate tiles. The effect is the same in that you only write RUL2 code connecting to pure diagonals (in and out). (The orthogonal and diagonal surrogate tiles are chosen from a hard-coded list of IIDs.) ### Goals of this PR - [x] Write a [script](https://github.com/NAMTeam/Network-Addon-Mod/blob/7d2db2d9e33ec8f16ee0fc8a316c83d6123aa600/src/main/scala/scripts/RedundantAdjacenciesChecker.scala) to identify redundant RUL2 code (i.e. covered by DLL + other RUL2 code). - [x] Remove adjacencies from metarules: - [x] [FlexFlyRuleGenerator](https://github.com/NAMTeam/Network-Addon-Mod/blob/staging/src/main/scala/module/flexfly/FlexFlyRuleGenerator.scala) - [x] [OST generator](https://github.com/NAMTeam/Network-Addon-Mod/blob/staging/src/main/scala/module/onslope.scala) - [x] [RhwRuleGenerator](https://github.com/NAMTeam/Network-Addon-Mod/blob/staging/src/main/scala/module/RhwRuleGenerator.scala) - [x] [RealRailwayRuleGenerator](https://github.com/NAMTeam/Network-Addon-Mod/blob/staging/src/main/scala/module/RealRailwayRuleGenerator.scala) (contained no adjacencies in the first place) - [x] [SamRuleGenerator](https://github.com/NAMTeam/Network-Addon-Mod/blob/staging/src/main/scala/module/SamRuleGenerator.scala) (covered by [meta-sam](staging...meta-sam) branch) - [x] Run removal script and regenerate metarule-based RUL2 code (needs to rerun after previous step is complete). - [x] Sight the remaining RUL2 code in the repository and remove redundant parts _manually_: - [x] Some files seem to consist of almost entirely adjacencies only, for example: * [Controller/RUL2/07_RHW/Sec7b_BaseNetwork](https://github.com/NAMTeam/Network-Addon-Mod/tree/staging/Controller/RUL2/07_RHW/Sec7b_BaseNetwork/) * [Controller/RUL2/08_NWM/](https://github.com/NAMTeam/Network-Addon-Mod/tree/staging/Controller/RUL2/08_NWM/) Partially scripted, see [remove-rhw-adjacencies.py](https://github.com/NAMTeam/Network-Addon-Mod/blob/9c1152880f93843277df3a3d33e6168958dc904e/src/scripts/remove-rhw-adjacencies.py) and [remove-nwm-adjacencies.py](https://github.com/NAMTeam/Network-Addon-Mod/blob/9c1152880f93843277df3a3d33e6168958dc904e/src/scripts/remove-nwm-adjacencies.py). - [x] Some of the handwritten adjacency code seems to have some bugs in it. Partially scripted, see [SegmentOrientationChecker](https://github.com/NAMTeam/Network-Addon-Mod/blob/9c1152880f93843277df3a3d33e6168958dc904e/src/main/scala/scripts/SegmentOrientationChecker.scala) and [MissingInstanceChecker](https://github.com/NAMTeam/Network-Addon-Mod/blob/9c1152880f93843277df3a3d33e6168958dc904e/src/main/scala/scripts/MissingInstanceChecker.scala).
2 parents 23c0391 + 75fd257 commit a93c7a5

893 files changed

Lines changed: 300818 additions & 10882407 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/scala.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
run: sbt generateLocales
3535
- name: Check for new conflicting RUL2 overrides
3636
run: SBT_OPTS="-Xmx2G" sbt conflictingOverridesCheck
37+
- name: Check for new segment orientation issues in RUL2 overrides
38+
run: sbt "runMain com.sc4nam.scripts.SegmentOrientationChecker"
3739

3840
lint:
3941
runs-on: ubuntu-latest

Controller/INRULs/RULConfig.txt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,17 @@ Source: RoadAdvanced/RUL08_Road_Advanced.rul
5959

6060
TGI: 0x0A5BCF4B 0xAA5BCF57 0x00000009
6161
Compressed: 1
62-
Source: StreetBasic/RUL09_Street_Basic.rul
62+
Source: StreetBasic/RUL09_Street_Basic_Header.rul
63+
Source: StreetBasic/StreetBasic.rul
64+
Source: StreetBasic/FractionalAngle.rul
6365

6466
TGI: 0x0A5BCF4B 0xAA5BCF57 0x0000000A
6567
Compressed: 1
66-
Source: StreetAdvanced/RUL0A_Street_Advanced.rul
68+
Source: StreetAdvanced/RUL0A_Street_Advanced_Header.rul
69+
Source: StreetAdvanced/FractionalAngle.rul
70+
Source: StreetAdvanced/Roundabouts.rul
71+
Source: StreetAdvanced/WideRadiusCurves.rul
72+
Source: StreetAdvanced/Miscellaneous.rul
6773

6874
TGI: 0x0A5BCF4B 0xAA5BCF57 0x0000000B
6975
Compressed: 1
@@ -165,11 +171,17 @@ Source: RoadAdvanced/RUL08_Road_Advanced.rul
165171

166172
TGI: 0x0A5BCF4B 0xAA5BCF57 0x00000009
167173
Compressed: 1
168-
Source: StreetBasic/RUL09_Street_Basic.rul
174+
Source: StreetBasic/RUL09_Street_Basic_Header.rul
175+
Source: StreetBasic/StreetBasic.rul
176+
Source: StreetBasic/FractionalAngle.rul
169177

170178
TGI: 0x0A5BCF4B 0xAA5BCF57 0x0000000A
171179
Compressed: 1
172-
Source: StreetAdvanced/RUL0A_Street_Advanced.rul
180+
Source: StreetAdvanced/RUL0A_Street_Advanced_Header.rul
181+
Source: StreetAdvanced/FractionalAngle.rul
182+
Source: StreetAdvanced/Roundabouts.rul
183+
Source: StreetAdvanced/WideRadiusCurves.rul
184+
Source: StreetAdvanced/Miscellaneous.rul
173185

174186
TGI: 0x0A5BCF4B 0xAA5BCF57 0x0000000B
175187
Compressed: 1
@@ -261,7 +273,10 @@ Source: RoadAdvanced/RUL08_Road_Advanced_Lite.rul
261273

262274
TGI: 0x0A5BCF4B 0xAA5BCF57 0x00000009
263275
Compressed: 1
264-
Source: StreetBasic/RUL09_Street_Basic.rul
276+
Source: StreetBasic/RUL09_Street_Basic_Header.rul
277+
Source: StreetBasic/LegacyDiagonalStreets.rul
278+
Source: StreetBasic/StreetBasic.rul
279+
Source: StreetBasic/FractionalAngle.rul
265280

266281
TGI: 0x0A5BCF4B 0xAA5BCF57 0x0000000A
267282
Compressed: 1

Controller/INRULs/RoadAdvanced/RUL08_Road_Advanced.rul

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,59 +3212,55 @@
32123212
2,5,2,2,?,?
32133213
3,0,0x5F06BA00,3,0
32143214
;
3215-
;Configurations for orthogonal road piece flipped; 5F06BB00
3216-
;
32173215
1,2,0,2,2
32183216
2,5,2,?,?,2
32193217
2,6,2,2,?,?
32203218
2,7,?,2,2,?
3221-
3,0,0x5F06BB00,3,0
3219+
3,0,0x5F06BA00,1,1
32223220
;
32233221
1,2,2,0,2
32243222
2,7,2,2,?,?
32253223
2,8,?,2,2,?
32263224
2,1,?,?,2,2
3227-
3,0,0x5F06BB00,0,0
3225+
3,0,0x5F06BA00,0,1
32283226
;
32293227
1,2,2,2,0
32303228
2,1,?,2,2,?
32313229
2,2,?,?,2,2
32323230
2,3,2,?,?,2
3233-
3,0,0x5F06BB00,1,0
3231+
3,0,0x5F06BA00,3,1
32343232
;
32353233
1,0,2,2,2
32363234
2,3,?,?,2,2
32373235
2,4,2,?,?,2
32383236
2,5,2,2,?,?
3239-
3,0,0x5F06BB00,2,0
3237+
3,0,0x5F06BA00,2,1
32403238
;
3241-
;Configurations for right-hook diagonal road piece; 5F06BF00
3239+
;Configurations for diagonal (away) road piece; 5F06BE00
32423240
;
32433241
1,13,0,2,2
32443242
2,5,2,?,?,2
32453243
2,6,2,2,?,?
32463244
2,7,?,2,2,?
3247-
3,0,0x5F06BF00,3,0
3245+
3,0,0x5F06BE00,1,1
32483246
;
32493247
1,2,13,0,2
32503248
2,7,2,2,?,?
32513249
2,8,?,2,2,?
32523250
2,1,?,?,2,2
3253-
3,0,0x5F06BF00,0,0
3251+
3,0,0x5F06BE00,0,1
32543252
;
32553253
1,2,2,13,0
32563254
2,1,?,2,2,?
32573255
2,2,?,?,2,2
32583256
2,3,2,?,?,2
3259-
3,0,0x5F06BF00,1,0
3257+
3,0,0x5F06BE00,3,1
32603258
;
32613259
1,0,2,2,13
32623260
2,3,?,?,2,2
32633261
2,4,2,?,?,2
32643262
2,5,2,2,?,?
3265-
3,0,0x5F06BF00,2,0
3266-
;
3267-
;Configurations for right-hook diagonal road piece flipped; 5F06BE00
3263+
3,0,0x5F06BE00,2,1
32683264
;
32693265
1,0,11,2,2
32703266
2,5,2,?,?,2
@@ -3290,33 +3286,31 @@
32903286
2,5,2,2,?,?
32913287
3,0,0x5F06BE00,3,0
32923288
;
3293-
;Configurations for left-hook diagonal road piece; 5F06B900
3289+
;Configurations for diagonal (back) road piece; 5F06B800
32943290
;
32953291
1,11,0,2,2
32963292
2,5,2,?,?,2
32973293
2,6,2,2,?,?
32983294
2,7,?,2,2,?
3299-
3,0,0x5F06B900,3,0
3295+
3,0,0x5F06B800,1,1
33003296
;
33013297
1,2,11,0,2
33023298
2,7,2,2,?,?
33033299
2,8,?,2,2,?
33043300
2,1,?,?,2,2
3305-
3,0,0x5F06B900,0,0
3301+
3,0,0x5F06B800,0,1
33063302
;
33073303
1,2,2,11,0
33083304
2,1,?,2,2,?
33093305
2,2,?,?,2,2
33103306
2,3,2,?,?,2
3311-
3,0,0x5F06B900,1,0
3307+
3,0,0x5F06B800,3,1
33123308
;
33133309
1,0,2,2,11
33143310
2,3,?,?,2,2
33153311
2,4,2,?,?,2
33163312
2,5,2,2,?,?
3317-
3,0,0x5F06B900,2,0
3318-
;
3319-
;Configurations for left-hook diagonal road piece flipped; 5F06B800
3313+
3,0,0x5F06B800,2,1
33203314
;
33213315
1,0,13,2,2
33223316
2,5,2,?,?,2

0 commit comments

Comments
 (0)