@@ -333,6 +333,7 @@ private void UpdateCaches()
333
333
_pinMameIdToSwitchIdMappings . Clear ( ) ;
334
334
_switchIdToPinMameIdMappings . Clear ( ) ;
335
335
336
+ // check aliases first (the switches/coils that aren't an integer)
336
337
foreach ( var alias in _game . AvailableAliases ) {
337
338
switch ( alias . AliasType ) {
338
339
case AliasType . Switch :
@@ -352,16 +353,30 @@ private void UpdateCaches()
352
353
}
353
354
}
354
355
355
-
356
+ // retrieve the game's switches
356
357
foreach ( var @switch in _game . AvailableSwitches ) {
357
358
_switches [ @switch . Id ] = @switch ;
358
359
359
- if ( int . TryParse ( @switch . Id , out int pinMameId ) ) {
360
+ if ( int . TryParse ( @switch . Id , out var pinMameId ) ) {
360
361
_pinMameIdToSwitchIdMappings [ pinMameId ] = @switch . Id ;
361
362
_switchIdToPinMameIdMappings [ @switch . Id ] = pinMameId ;
363
+
364
+ // add mappings with prefixed 0.
365
+ if ( pinMameId < 10 ) {
366
+ _switchIdToPinMameIdMappings [ "0" + @switch . Id ] = pinMameId ;
367
+ _switchIdToPinMameIdMappings [ "00" + @switch . Id ] = pinMameId ;
368
+
369
+ _switches [ "0" + @switch . Id ] = @switch ;
370
+ _switches [ "00" + @switch . Id ] = @switch ;
371
+ }
372
+ if ( pinMameId < 100 ) {
373
+ _switchIdToPinMameIdMappings [ "0" + @switch . Id ] = pinMameId ;
374
+ _switches [ "0" + @switch . Id ] = @switch ;
375
+ }
362
376
}
363
377
}
364
378
379
+ // retrieve the game's coils
365
380
foreach ( var coil in _game . AvailableCoils ) {
366
381
_coils [ coil . Id ] = coil ;
367
382
@@ -371,6 +386,7 @@ private void UpdateCaches()
371
386
}
372
387
}
373
388
389
+ // retrieve the game's lamps
374
390
foreach ( var lamp in _game . AvailableLamps ) {
375
391
_lamps [ lamp . Id ] = lamp ;
376
392
0 commit comments