]> git.smokeofanarchy.ru Git - space-station-14.git/commit
Fix usages of TryIndex() (#39124)
authorPieter-Jan Briers <pieterjan.briers+git@gmail.com>
Tue, 9 Sep 2025 16:17:56 +0000 (18:17 +0200)
committerGitHub <noreply@github.com>
Tue, 9 Sep 2025 16:17:56 +0000 (18:17 +0200)
commit0c9752027623a22be7367b453e2a8e82fc68c03c
treef0d7c4fc06f6cbf55850ca4236285e5e571218f7
parentfca45851cc7d7c146615c3dd68f9dec5a89cefbf
Fix usages of TryIndex() (#39124)

* Fix usages of TryIndex()

Most usages of TryIndex() were using it incorrectly. Checking whether prototype IDs specified in prototypes actually existed before using them. This is not appropriate as it's just hiding bugs that should be getting caught by the YAML linter and other tools. (#39115)

This then resulted in TryIndex() getting modified to log errors (https://github.com/space-wizards/RobustToolbox/commit/94f98073b07bd3fa3133ae6799b34d90f46f467e), which is incorrect as it causes false-positive errors in proper uses of the API: external data validation. (#39098)

This commit goes through and checks every call site of TryIndex() to see whether they were correct. Most call sites were replaced with the new Resolve(), which is suitable for these "defensive programming" use cases.

Fixes #39115

Breaking change: while doing this I noticed IdCardComponent and related systems were erroneously using ProtoId<AccessLevelPrototype> for job prototypes. This has been corrected.

* fix tests

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
136 files changed:
Content.Client/Access/UI/AccessOverriderWindow.xaml.cs
Content.Client/Access/UI/GroupedAccessLevelChecklist.xaml.cs
Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs
Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs
Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs
Content.Client/Atmos/AlignAtmosPipeLayers.cs
Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs
Content.Client/BarSign/BarSignSystem.cs
Content.Client/BarSign/Ui/BarSignBoundUserInterface.cs
Content.Client/Cargo/UI/BountyEntry.xaml.cs
Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs
Content.Client/Chat/TypingIndicator/TypingIndicatorVisualizerSystem.cs
Content.Client/Clothing/UI/ChameleonBoundUserInterface.cs
Content.Client/Clothing/UI/ChameleonMenu.xaml.cs
Content.Client/Construction/ConstructionSystem.cs
Content.Client/Construction/UI/ConstructionMenuPresenter.cs
Content.Client/Damage/DamageVisualsSystem.cs
Content.Client/Doors/DoorSystem.cs
Content.Client/Ghost/GhostRoleRadioMenu.xaml.cs
Content.Client/Guidebook/DocumentParsingManager.cs
Content.Client/Implants/ImplanterSystem.cs
Content.Client/Implants/UI/ChameleonControllerMenu.xaml.cs
Content.Client/Implants/UI/ImplanterStatusControl.cs
Content.Client/Lathe/UI/LatheMenu.xaml.cs
Content.Client/Lobby/LobbyUIController.cs
Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Content.Client/Lobby/UI/Loadouts/LoadoutContainer.xaml.cs
Content.Client/Lobby/UI/Loadouts/LoadoutGroupContainer.xaml.cs
Content.Client/Lobby/UI/Loadouts/LoadoutWindow.xaml.cs
Content.Client/Overlays/EntityHealthBarOverlay.cs
Content.Client/Overlays/ShowCriminalRecordIconsSystem.cs
Content.Client/Overlays/ShowHealthIconsSystem.cs
Content.Client/Overlays/ShowJobIconsSystem.cs
Content.Client/Overlays/ShowMindShieldIconsSystem.cs
Content.Client/Overlays/StencilOverlay.cs
Content.Client/RCD/RCDMenuBoundUserInterface.cs
Content.Client/Radio/Ui/IntercomMenu.xaml.cs
Content.Client/Revolutionary/RevolutionarySystem.cs
Content.Client/Silicons/StationAi/StationAiCustomizationMenu.xaml.cs
Content.Client/SprayPainter/SprayPainterSystem.cs
Content.Client/Storage/Visualizers/EntityStorageVisualizerSystem.cs
Content.Client/Store/Ui/StoreWithdrawWindow.xaml.cs
Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs
Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs
Content.IntegrationTests/Tests/ContrabandTest.cs
Content.IntegrationTests/Tests/Lathe/LatheTest.cs
Content.IntegrationTests/Tests/Minds/MindTests.cs
Content.IntegrationTests/Tests/PostMapInitTest.cs
Content.Server/Access/Systems/AgentIDCardSystem.cs
Content.Server/Access/Systems/IdCardConsoleSystem.cs
Content.Server/Access/Systems/PresetIdCardSystem.cs
Content.Server/Administration/Commands/ExplosionCommand.cs
Content.Server/Advertise/EntitySystems/SpeakOnUIClosedSystem.cs
Content.Server/Anomaly/Effects/InnerBodyAnomalySystem.cs
Content.Server/Audio/Jukebox/JukeboxSystem.cs
Content.Server/Cargo/Systems/CargoSystem.Bounty.cs
Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Content.Server/Chat/Systems/ChatSystem.cs
Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs
Content.Server/Cloning/CloningSystem.cs
Content.Server/Construction/ConstructionSystem.Guided.cs
Content.Server/Damage/ForceSay/DamageForceSaySystem.cs
Content.Server/Damage/Systems/ExaminableDamageSystem.cs
Content.Server/Delivery/DeliverySystem.cs
Content.Server/Destructible/Thresholds/Behaviors/WeightedSpawnEntityBehavior.cs
Content.Server/EntityEffects/EntityEffectSystem.cs
Content.Server/GameTicking/Rules/AntagLoadProfileRuleSystem.cs
Content.Server/GameTicking/Rules/VariationPass/PuddleMessVariationPassSystem.cs
Content.Server/Ghost/Roles/GhostRoleSystem.cs
Content.Server/Ghost/SpookySpeakerSystem.cs
Content.Server/Implants/ChameleonControllerSystem.cs
Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
Content.Server/Lathe/LatheSystem.cs
Content.Server/NameIdentifier/NameIdentifierSystem.cs
Content.Server/Parallax/BiomeSystem.cs
Content.Server/Players/JobWhitelist/JobWhitelistManager.cs
Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs
Content.Server/Polymorph/Systems/PolymorphSystem.cs
Content.Server/Polymorph/Toolshed/PolymorphCommand.cs
Content.Server/Procedural/DungeonJob/DungeonJob.Biome.cs
Content.Server/Procedural/DungeonJob/DungeonJob.MiddleConnection.cs
Content.Server/Procedural/DungeonJob/DungeonJob.Ore.cs
Content.Server/Radiation/Systems/RadiationProtectionSystem.cs
Content.Server/Radio/EntitySystems/RadioSystem.cs
Content.Server/Roles/RoleSystem.cs
Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs
Content.Server/Silicons/Borgs/BorgSwitchableTypeSystem.cs
Content.Server/Spawners/EntitySystems/ContainerSpawnPointSystem.cs
Content.Server/Speech/EmotesMenuSystem.cs
Content.Server/Spreader/SpreaderSystem.cs
Content.Server/Station/Systems/StationJobsSystem.Roundstart.cs
Content.Server/Station/Systems/StationSpawningSystem.cs
Content.Server/StationEvents/EventManagerSystem.cs
Content.Server/StationEvents/Events/GreytideVirusRule.cs
Content.Server/SurveillanceCamera/Systems/SurveillanceCameraRouterSystem.cs
Content.Server/SurveillanceCamera/Systems/SurveillanceCameraSystem.cs
Content.Server/Telephone/TelephoneSystem.cs
Content.Server/Traitor/Uplink/UplinkSystem.cs
Content.Server/Traits/TraitSystem.cs
Content.Server/Trigger/Systems/SpeakOnTriggerSystem.cs
Content.Server/Wires/WiresSystem.cs
Content.Server/Zombies/ZombieSystem.cs
Content.Shared/Access/Components/AccessComponent.cs
Content.Shared/Access/Components/IdCardComponent.cs
Content.Shared/Access/Components/IdCardConsoleComponent.cs
Content.Shared/Access/Systems/SharedAccessSystem.cs
Content.Shared/Atmos/EntitySystems/SharedAtmosPipeLayersSystem.cs
Content.Shared/BarSign/BarSignSystem.cs
Content.Shared/Body/Systems/SharedBloodstreamSystem.cs
Content.Shared/Cargo/Prototypes/CargoProductPrototype.cs
Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs
Content.Shared/Clothing/LoadoutSystem.cs
Content.Shared/ComponentTable/SharedComponentTableSystem.cs
Content.Shared/Construction/MachinePartSystem.cs
Content.Shared/Containers/ContainerCompSystem.cs
Content.Shared/Damage/Systems/DamageableSystem.cs
Content.Shared/Humanoid/Markings/MarkingManager.cs
Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs
Content.Shared/Light/EntitySystems/UnpoweredFlashlightSystem.cs
Content.Shared/Nutrition/EntitySystems/FoodSequenceSystem.cs
Content.Shared/Nutrition/EntitySystems/HungerSystem.cs
Content.Shared/Nutrition/EntitySystems/ThirstSystem.cs
Content.Shared/Nutrition/FoodMetamorphRules/FoodMetamorphRule.cs
Content.Shared/Preferences/HumanoidCharacterProfile.cs
Content.Shared/RCD/Systems/RCDSystem.cs
Content.Shared/Roles/JobRequirement/DepartmentTimeRequirement.cs
Content.Shared/Roles/Jobs/SharedJobSystem.cs
Content.Shared/Roles/SharedRoleSystem.cs
Content.Shared/Silicons/Borgs/SharedBorgSwitchableTypeSystem.cs
Content.Shared/Silicons/StationAi/SharedStationAiSystem.Customization.cs
Content.Shared/SprayPainter/SharedSprayPainterSystem.cs
Content.Shared/Station/SharedStationSpawningSystem.cs
Content.Shared/StatusEffectNew/StatusEffectsSystem.cs
Content.Shared/Storage/EntitySystems/DumpableSystem.cs
Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs
Content.Shared/StoryGen/EntitySystems/StoryGeneratorSystem.cs