Gettings defensive over AIGetLeadDir

Gettings defensive over AIGetLeadDir - some issues were reported in #2437

This PR depends on #2546 to get it compiling in Visual Studio again.