Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image constructor argument handling #1479

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions OpenDreamRuntime/Objects/Types/DreamObjectImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ends up skipping the 3rd argument

if (!loc.IsNull) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loc.IsNull will always be false here because TryGetValueAsDreamObject() will return true for a null object.

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
Expand Down
Loading