From 25dbef3a8feeac0d70aa396ed65d8e003a3ac3d5 Mon Sep 17 00:00:00 2001 From: Penelope Haze Date: Sat, 7 Oct 2023 09:18:17 -0500 Subject: [PATCH] Fix image constructor argument handling --- OpenDreamRuntime/Objects/Types/DreamObjectImage.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamObjectImage.cs b/OpenDreamRuntime/Objects/Types/DreamObjectImage.cs index 95196862cb..d5a1a621f6 100644 --- a/OpenDreamRuntime/Objects/Types/DreamObjectImage.cs +++ b/OpenDreamRuntime/Objects/Types/DreamObjectImage.cs @@ -44,17 +44,21 @@ public override void Initialize(DreamProcArguments args) { .Warning($"Attempted to create an /image from {icon}. This is invalid and a default image was created instead."); } - int argIndex = 1; + int startIndex = 0; DreamValue loc = args.GetArgument(1); - if (loc.TryGetValueAsDreamObject(out _loc)) { // If it's not a DreamObject, it's actually icon_state and not loc - argIndex = 2; + if (!loc.TryGetValueAsDreamObject(out _loc)) { // If it's not a DreamObject, it's actually icon_state and not loc + startIndex = 1; + if (!loc.IsNull) { + AtomManager.SetAppearanceVar(Appearance, "icon_state", loc); + } } - foreach (string argName in IconCreationArgs) { - var arg = args.GetArgument(argIndex++); + for (int i = startIndex; i < IconCreationArgs.Length; i++) { + var arg = args.GetArgument(i + 2); if (arg.IsNull) continue; + string argName = IconCreationArgs[i]; AtomManager.SetAppearanceVar(Appearance, argName, arg); if (argName == "dir") { // If a dir is explicitly given in the constructor then overlays using this won't use their owner's dir