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 pickup combining over the maximum stack size. #1124

Merged
merged 5 commits into from Jun 26, 2014

Conversation

Projects
None yet
5 participants
@Howaner
Contributor

Howaner commented Jun 24, 2014

Fix #1114

@madmaxoft

This comment has been minimized.

Show comment
Hide comment
@madmaxoft

madmaxoft Jun 24, 2014

Member

I think we can do better.

If you throw 3 stacks of 33 stone each next to each other, this code will fail to combine any of them; we could make code that combines that into (33 + 31) + (2 + 33).

Member

madmaxoft commented Jun 24, 2014

I think we can do better.

If you throw 3 stacks of 33 stone each next to each other, this code will fail to combine any of them; we could make code that combines that into (33 + 31) + (2 + 33).

@Howaner

This comment has been minimized.

Show comment
Hide comment
@Howaner

Howaner Jun 24, 2014

Contributor

done

Contributor

Howaner commented Jun 24, 2014

done

@madmaxoft

This comment has been minimized.

Show comment
Hide comment
@madmaxoft

madmaxoft Jun 24, 2014

Member

Ouch, this has a tiny little bug that I had not seen coming.

Consider two pickups close to each other, A has 64 stone, B has 1 stone. The code will first try to move B's 1 stone into A's 64 stone, won't work, nothing will be done. But then it will do the callback in the reverse direction - trying to move A's 64 stone into B's 1 stone, which will work partially by moving 63 stone from A to B. Now A has 1 stone and B has 64 stone. In the next tick, the situation repeats with the pickups reversed. So this makes the server send an update packet for both entities on each world tick :(

Either we solve by checking the pickup ID and moving only from a larger UniqueID to a smaller UniqueID, or we decide that the first solution is enough for our needs. Which will it be?

Member

madmaxoft commented Jun 24, 2014

Ouch, this has a tiny little bug that I had not seen coming.

Consider two pickups close to each other, A has 64 stone, B has 1 stone. The code will first try to move B's 1 stone into A's 64 stone, won't work, nothing will be done. But then it will do the callback in the reverse direction - trying to move A's 64 stone into B's 1 stone, which will work partially by moving 63 stone from A to B. Now A has 1 stone and B has 64 stone. In the next tick, the situation repeats with the pickups reversed. So this makes the server send an update packet for both entities on each world tick :(

Either we solve by checking the pickup ID and moving only from a larger UniqueID to a smaller UniqueID, or we decide that the first solution is enough for our needs. Which will it be?

@madmaxoft

This comment has been minimized.

Show comment
Hide comment
@madmaxoft

madmaxoft Jun 24, 2014

Member

@worktycho Travis seems to have encountered an interesting failure, care to have a look?

Member

madmaxoft commented Jun 24, 2014

@worktycho Travis seems to have encountered an interesting failure, care to have a look?

@NiLSPACE

This comment has been minimized.

Show comment
Hide comment
@NiLSPACE

NiLSPACE Jun 24, 2014

Member

Wouldn't it work if you check if pickup A or B is full?

Member

NiLSPACE commented Jun 24, 2014

Wouldn't it work if you check if pickup A or B is full?

@Howaner

This comment has been minimized.

Show comment
Hide comment
@Howaner

Howaner Jun 24, 2014

Contributor

done

Contributor

Howaner commented Jun 24, 2014

done

@worktycho

This comment has been minimized.

Show comment
Hide comment
@worktycho

worktycho Jun 24, 2014

Member

@madmaxoft Its the copyblocks test. If it doesn't complete in under 10 minutes Travis thinks the build has stalled. Possibly we should reduce its length a little.

Member

worktycho commented Jun 24, 2014

@madmaxoft Its the copyblocks test. If it doesn't complete in under 10 minutes Travis thinks the build has stalled. Possibly we should reduce its length a little.

@tigerw

This comment has been minimized.

Show comment
Hide comment
@tigerw

tigerw Jun 24, 2014

Member

Wouldn't it work if you check if pickup A or B is full?

I agree.

Member

tigerw commented Jun 24, 2014

Wouldn't it work if you check if pickup A or B is full?

I agree.

@madmaxoft

This comment has been minimized.

Show comment
Hide comment
@madmaxoft

madmaxoft Jun 25, 2014

Member

You're right, checking if the pickup was full would work, too. However, we're already checking the UniqueID, so unlike the fullness check, the ID check doesn't cost us anything at all.

Member

madmaxoft commented Jun 25, 2014

You're right, checking if the pickup was full would work, too. However, we're already checking the UniqueID, so unlike the fullness check, the ID check doesn't cost us anything at all.

@Howaner

This comment has been minimized.

Show comment
Hide comment
@Howaner

Howaner Jun 26, 2014

Contributor

done

Contributor

Howaner commented Jun 26, 2014

done

@madmaxoft madmaxoft merged commit cba273d into cuberite:master Jun 26, 2014

2 checks passed

continuous-integration/appveyor AppVeyor build succeeded
Details
continuous-integration/travis-ci The Travis CI build passed
Details

@Howaner Howaner deleted the Howaner:Pickups branch Aug 5, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment