more aicombat pathfinding fixes

Zini, would you mind cherry picking a6f201c and 1105f6e please.

These are optional, required for MSVC 64bit only: 8b492a3, beac817 and 97ebb7f