The motivation for d1520 is the following:
Create a catapult. Tell it to start unpacking. Before it finishes, give it a move or garrison command. It should cancel unpacking by itself and start moving. Try this nearby an enemy under conditions where clicking the cancel unpacking button directly would fail due to #5175. When you give it the walk command, again it should cancel unpacking and start moving.
These cases should also be tested:
While the catapult is out of range of an enemy building: begin to unpack the catapult. Before it finishes, tell it to attack the enemy building. The catapult should cancel unpacking and immediately begin moving within range, and then start to unpack and attack once it is in range.
While the catapult is out of range of an enemy building: unpack the catapult fully. Begin to pack the catapult. Before it finishes, tell it to attack the enemy building. The catapult should continue packing, then move within range, then unpack and attack.
While the catapult is in range of an enemy building, begin to unpack the catapult. Before it finishes, tell it to attack the enemy building. The catapult should finish unpacking, then attack.
While the catapult is in range of an enemy building, unpack the catapult fully. Begin to pack the catapult. Before it finishes, tell it to attack the enemy building. The catapult should cancel unpacking immediately, then attack.
Begin unpacking the catapult. Before it finishes unpacking, place a foundation at its location and begin building it. The catapult should cancel unpacking and leave the foundation. Then it should resume unpacking.
All three pieces of Order.LeaveFoundation code were touched, so it is necessary to make sure that animals, units in formation, and individual units will leave a foundation as expected. Note there is currently a bug with units in formation having difficulty leaving the foundation, fixed in D2424 (not the result of this patch).