Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFix pickup combining over the maximum stack size. #1124
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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).
|
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). |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
done |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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?
|
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? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
madmaxoft
Jun 24, 2014
Member
@worktycho Travis seems to have encountered an interesting failure, care to have a look?
|
@worktycho Travis seems to have encountered an interesting failure, care to have a look? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Wouldn't it work if you check if pickup A or B is full? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
done |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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.
|
@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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
I agree. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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.
|
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
added some commits
Jun 26, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
done |
Howaner commentedJun 24, 2014
Fix #1114