Let me try to draw this (and this is when everyone with any artistic ability should quickly look away...):
- VTOL_blank.png (8.29 KiB) Viewed 7323 times
(You need to scroll the image...)
Here we have two VTOLs, A and B, that have expended their ammo. A is closer to the rearm pads on the left, while B is closer to the rearm pads on the right. The rearm pads on the left are all busy rearming VTOLs. The rearm pads on the right are all idle.
- VTOL_315.png (10.7 KiB) Viewed 7323 times
This is how I understand 3.1.5 and earlier behaviour. VTOL B will go rearm to the right. VTOL A will travel to the closest rearm pad to the left, and start to park next to it, setting itself to the "waiting to rearm" state. Before it has managed to land, however, one of the rearm pads on the right will have noticed that it is waiting to rearm, and will pull it in. It would then fly (potentially across the map) to land on the rearm pads on the right. Note that since allied VTOL pads will happily snatch and rearm your VTOLs, this kind of long distance rebasing is not really that far fetched in many player games. We could change it so that rearm pads can snatch targets mid-air, but this makes it even more complicated, and could lead to some quite surprising and dangerous flight paths.
- VTOL_simpler.png (11.61 KiB) Viewed 7323 times
This is I think a simpler solution, which is what Berserker Cyborg is suggesting above. Once the VTOL is out of ammo, it finds an available rearm pad, assigns it and uses it. If there are none available, they go the nearest busy one. In the all busy case, it behaves similar to 3.1.5. This variant is simpler, less surprising, and I think leads to better results overall.
Both the above variants have the consequence that if you have 49 busy rearm pads at the far end of the map, 1 VTOL pad close to the enemy base, and 100 VTOLs coming back to rearm, then all 100 VTOLs will land at the 1 close rearm pad. I think any optimal solution would require each rearm pad to have a rearm queue, as suggested above by Bethrezen. The returning VTOL can then find out which rearm pad to wait by simply by checking the length of each pad's queue, and add itself to the one with the shortest queue. This solution might actually save us a bit of CPU time, since currently each idle pad iterates over every allied droid every frame to check for potential rearm targets, which is a bit silly.