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

Spring.ShareResources(teamID, "units", nil) breaks #1826

Open
sprunk opened this issue Dec 18, 2024 · 0 comments · May be fixed by #1837
Open

Spring.ShareResources(teamID, "units", nil) breaks #1826

sprunk opened this issue Dec 18, 2024 · 0 comments · May be fixed by #1837
Labels
area: Lua API bug Something isn't working

Comments

@sprunk
Copy link
Collaborator

sprunk commented Dec 18, 2024

  • A) ✅ Spring.ShareResources(teamID, "metal", nil) is correctly rejected (3rd arg is amount of resource, in this case metal, so has to be a number).
  • B) ✅ Spring.ShareResources(teamID, "units") works. It shares whatever is selected - whether this is good behaviour is not in the scope of this ticket.
  • C) ❔ Spring.ShareResources(teamID, "units", 123) is accepted and behaves the same as not passing any arg at all, even though the 3rd arg is meaningless. This is just a piece of information for context. I am not specifying either way whether this should be rejected.
  • D) ❌ Spring.ShareResources(teamID, "units", nil) is rejected. The request is to make an explicit nil accepted.

The use case is that I want to wrap the function:

local originalShareResources = Spring.ShareResources
function Spring.ShareResources(teamID, resourceType, amount)
	-- some logic here...
	originalShareResources(teamID, resourceType, amount) -- then forward the original args
end

but doing it like this turns an original working 2-arg call (3rd arg and further are "none" in C parlance), like case B above, into a 3-arg call with the 3rd arg equal to nil, like case D.

This is a general issue where passing a bunch of extra nils at the end of any function should not break anything, but figuring out whether anything else is broken this way is outside of the scope of this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Lua API bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant