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

List iterator wrongly return first item when query by Begin() #6085

Closed
DorpsGek opened this issue Aug 14, 2014 · 8 comments
Closed

List iterator wrongly return first item when query by Begin() #6085

DorpsGek opened this issue Aug 14, 2014 · 8 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

krinn opened the ticket and wrote:

Ok, so i have trigger that with :
zlist.Sort(GSList.SORT_BY_VALUE, GSList.SORT_ASCENDING);
when calling zlist.Begin() the first time, it return the correct item, but another try on the function return always a bad value and the good one is store in Next()

Here's my gs that will break when the return value isn't the one expect and a savegame that trigger it (make it run quick it need two calls to trigger it) as the first Begin() will return correct value.

Look at eval.nut line 913 for the function code.

Attachments

Reported version: trunk
Operating system: All


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

krinn wrote:

Begin() Next() documentation need a less blur description.
Returns:
the item value of the first item.

Begin() return the first item, but "item value of the first item" is not clear and may tell it return the "value of first item".
(as i suppose someone will need to dig in script_list.cpp to fix the bug, can be fine to alter that while doing it).


This comment was imported from FlySpray: https://bugs.openttd.org/task/6085#comment13447

@DorpsGek
Copy link
Member Author

krinn wrote:

Adding a log filtered with only the GS output.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6085#comment13448

@DorpsGek
Copy link
Member Author

krinn wrote:

Adding info : all my trys to see the bug with 1.4 fail.
So i'm unlucky at seeing it with 1.4 or it do work correctly with 1.4.0 and fail with trunk r26728


This comment was imported from FlySpray: https://bugs.openttd.org/task/6085#comment13450

@DorpsGek
Copy link
Member Author

Rubidium wrote:

I see no reason why 1.4 would behave differently than trunk (@r26728). It might be fixed in r26736, can you confirm that or does it still happen? The documentation should be clearer since r26734.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6085#comment13454

@DorpsGek
Copy link
Member Author

krinn wrote:

Perfect! 4 times run over the same savegame (that i couldn't use with 1.4.0)

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6085#comment13456

@DorpsGek
Copy link
Member Author

frosch wrote:

Can you please check again with >= r26744. There were still issues.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6085#comment13458

@DorpsGek
Copy link
Member Author

krinn wrote:

i download and build this version -> http://hg.openttd.org/openttd/trunk.hg/rev/8a38e83175d0
and patch my GS with :

print("list after sort="+Utils.ArrayListToString(zlist));
print("begin="+zlist.Begin()+" next="+zlist.Next()+" isEnd="+zlist.IsEnd());
Scheduler.FullPlay(zlist);

function Scheduler::FullPlay(list)
{
print("");
list.Sort(GSList.SORT_BY_VALUE, GSList.SORT_ASCENDING);
print("list value+ascending : "+Utils.ArrayListToString(list));
print("begin="+list.Begin()+" next="+list.Next()+" IsEnd="+list.IsEnd());
list.Sort(GSList.SORT_BY_ITEM, GSList.SORT_ASCENDING);
print("list item+ascending : "+Utils.ArrayListToString(list));
print("begin="+list.Begin()+" next="+list.Next()+" IsEnd="+list.IsEnd());
list.Sort(GSList.SORT_BY_VALUE, GSList.SORT_DESCENDING);
print("list value+descending : "+Utils.ArrayListToString(list));
print("begin="+list.Begin()+" next="+list.Next()+" IsEnd="+list.IsEnd());
list.Sort(GSList.SORT_BY_ITEM, GSList.SORT_DESCENDING);
print("list item+descending : "+Utils.ArrayListToString(list));
print("begin="+list.Begin()+" next="+list.Next()+" IsEnd="+list.IsEnd());
}

And here's the output (nothing wrong for me there).
Note that items are made of vehicleID and their reliability, The only one that should always be in it is vehicleID=61 with reliability=0 because the AI have a bug with it and keep it in depot. The list may changes and catch vehicles with reliability < 50.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6085#comment13459

@DorpsGek
Copy link
Member Author

frosch closed the ticket.

Reason for closing: Fixed

in r26744


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

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant