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

AIList::AddItem - default value is not working #5638

Closed
DorpsGek opened this issue Jul 7, 2013 · 2 comments
Closed

AIList::AddItem - default value is not working #5638

DorpsGek opened this issue Jul 7, 2013 · 2 comments
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Jul 7, 2013

Kogut opened the ticket and wrote:

AIList::AddItem (int32 item, int32 value = 0) (...) the value is set to 0 by default.

but using it with only one parameter crashes AI with error message that parameter is missing

http://noai.openttd.org/api/trunk/classAIList.html# 6aa0c1a193ef1be1f594d5bd61729905

r25561

Reported version: trunk
Operating system: Windows


This issue was imported from FlySpray: https://bugs.openttd.org/task/5638
@DorpsGek
Copy link
Member Author

DorpsGek commented Jul 8, 2013

Rubidium wrote:

This is all because this is a relic from AIAbstractList, which had an AddItem with just the item parameter and not the value parameter. This method had a comment that mentioned the item would be added with the implicit 0 for value.

The AIList did have an AddItem with item and value parameters. During a rework in r20562 AIAbstractList and AIList were merged, and so were the AddItems from both methods. Or actually, the AddItem from AIAbstractList was used and the value parameter was added with a default value 0 so the callers of the old AddItem of AIAbstractList did not need to be changed.

This then gave the suggestion that default values would work in squirrel for this method. Actually, it can't as Squirrel doesn't provide any means for external methods to have default values.

So all that can be done is change the documentation.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5638#comment12393

@DorpsGek
Copy link
Member Author

DorpsGek commented Jul 8, 2013

Rubidium closed the ticket.

Reason for closing: Fixed

In r25577


This comment was imported from FlySpray: https://bugs.openttd.org/task/5638

@DorpsGek DorpsGek closed this as completed Jul 8, 2013
@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant