@@ -333,6 +333,7 @@ private void UpdateCaches()
333333 _pinMameIdToSwitchIdMappings . Clear ( ) ;
334334 _switchIdToPinMameIdMappings . Clear ( ) ;
335335
336+ // check aliases first (the switches/coils that aren't an integer)
336337 foreach ( var alias in _game . AvailableAliases ) {
337338 switch ( alias . AliasType ) {
338339 case AliasType . Switch :
@@ -352,16 +353,30 @@ private void UpdateCaches()
352353 }
353354 }
354355
355-
356+ // retrieve the game's switches
356357 foreach ( var @switch in _game . AvailableSwitches ) {
357358 _switches [ @switch . Id ] = @switch ;
358359
359- if ( int . TryParse ( @switch . Id , out int pinMameId ) ) {
360+ if ( int . TryParse ( @switch . Id , out var pinMameId ) ) {
360361 _pinMameIdToSwitchIdMappings [ pinMameId ] = @switch . Id ;
361362 _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+ }
362376 }
363377 }
364378
379+ // retrieve the game's coils
365380 foreach ( var coil in _game . AvailableCoils ) {
366381 _coils [ coil . Id ] = coil ;
367382
@@ -371,6 +386,7 @@ private void UpdateCaches()
371386 }
372387 }
373388
389+ // retrieve the game's lamps
374390 foreach ( var lamp in _game . AvailableLamps ) {
375391 _lamps [ lamp . Id ] = lamp ;
376392
0 commit comments